forked from vurtun/nuklear
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stddoc.c
141 lines (136 loc) · 4.84 KB
/
stddoc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/// ## About
/// - _stddoc.c_ is a tiny documentation generator for 60 programming languages.
/// - This page sample was auto-generated from the code comments found in `stddoc.c` file.
///
/// ## How does it work?
/// - Markdeep code comments are extracted from stdin and printed into stdout as a HTML file.
///
/// ## Supported languages
/// - `/// Three slashes comment` [ActionScript, AngelScript, C (C99), C#, C++, ChaiScript, D,
/// GameMonkey, GML, Go, Java, JavaScript, JetScript, jtc, Jx9, Kotlin, Neko, Object Pascal (Delphi),
/// Objective-C, Pawn, PHP, QuakeC, Rust, SASS, Scala, Squirrel, Swift, Vala, Wren, Xojo].
/// - `--- Three dashes comment` [Ada, AppleScript, Eiffel, Euphoria, Haskell, Lua, Occam,
/// PL/SQL, PSL, SGML, SPARK, SQL, Terra, TSQL, VHDL].
/// - `### Three hashes comment` [AWK, Bash, Bourne shell, C shell, Cobra, Maple, Maple,
/// Perl, Perl6, PowerShell, Python, R, Ruby, Seed7, Tcl].
///
/// ## Usage
/// - `stddoc < source.code > documentation.html`
///
/// ## Changelog
/// 2018/01/07
/// : Initial version (_v1.0.0_)
///
/// ## License
/// - rlyeh, unlicensed (~public domain).
#include <stdio.h>
int main() {
printf("%s\n", "<meta charset='utf-8' emacsmode='-*- markdown -*-'>");
printf("%s\n", "<link rel='stylesheet' href='https://casual-effects.com/markdeep/latest/apidoc.css?'>");
for( int fsm_S = 0, fsm_D = 0, fsm_H = 0; !feof(stdin); ) {
int chr = getc(stdin);
if( fsm_S > 3 || fsm_D > 3 || fsm_H > 3 ) {
putc(chr, stdout);
if( chr != '\r' && chr != '\n' ) continue;
}
/**/ if( fsm_S <= 2 && chr == '/' && !fsm_D && !fsm_H ) fsm_S++;
else if( fsm_S == 3 && chr == ' ' && !fsm_D && !fsm_H ) fsm_S++;
else if( fsm_D <= 2 && chr == '-' && !fsm_S && !fsm_H ) fsm_D++;
else if( fsm_D == 3 && chr == ' ' && !fsm_S && !fsm_H ) fsm_D++;
else if( fsm_H <= 2 && chr == '#' && !fsm_S && !fsm_D ) fsm_H++;
else if( fsm_H == 3 && chr == ' ' && !fsm_S && !fsm_D ) fsm_H++;
else fsm_S = fsm_D = fsm_H = 0;
}
printf("%s\n", "<script>markdeepOptions={tocStyle:'medium'};</script>");
printf("%s\n", "<!-- Markdeep: --><script src='https://casual-effects.com/markdeep/latest/markdeep.min.js?'></script>");
}
///
/// ## **Example page!**
///
/// Imaginary documentation page. Here would be some introduction text.
///
/// The table of contents that Markdeep produces is stuffed on the right side,
/// if the browser window is wide enough. Otherwise it is hidden.
///
/// ### Basic Markdeep
///
/// Regular styling like **bold**, _italics_, ~~strikethrough~~, `inline code`, etc. Lists as:
///
/// * A
/// * Bullet
/// * List
///
/// And:
///
/// 1. A
/// 1. Numbered
/// 1. List!
///
/// Symbol substitutions: a 45-degree turn; som x -> y arrows; some whoa ==> fancy <==> arrows.
///
/// Is this a definition list?
/// : Looks like one to me
/// Is that right?
/// : Possibly!
///
/// And a code listing:
///
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/// int main()
/// {
/// return 1;
/// }
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
///
///
/// ### Tables
///
/// Thing Name | Description |Notes
/// ------------------------|--------------------|-----
/// Yes | Yup! |
/// No | Nope :( |
/// FileNotFound | Doesn't find files | Pass `-sFIND_FILE=maybe` to maybe find them
///
///
/// ### Diagrams
///
/// ******************************************* Here's a text to the right of the diagram,
/// * +-----------------+ .-. * ain't that fancy. Pretty fancy indeed, I
/// * |\ | .-+ | * must say! Markdeep diagrams are generally
/// * | \ A-B *---+--> .--+ '--. * enclosed into a rectangle full made of `*`
/// * | \ | | Cloud! | * symbols; and are "drawn" using ASCII-art
/// * +---+-------------+ '-------------' * style, with `- | + / \ * o` etc.
/// ******************************************* Suh-weet!
///
/// Another random diagram, just because:
///
/// ********************
/// * +-+-+-+-*-o *
/// * / / ^ / *
/// * / v / / *
/// * +-+-+-+ *
/// ********************
///
/// ### Special notes
///
/// !!! Note
/// Hey I'm a note. Don't mind me, I'm just sitting here.
///
/// !!! WARNING
/// I'm a warning, perhaps. *Something might happen!*
///
/// !!! Error: Never Pass `nullptr` to a Shader
/// Invoking a shader with a null argument can seg fault.
/// This is a multi-line admonition.
///
/// Seriously, don't call shaders like that.
///
/// ### Embedding HTML
///
/// <pre>
/// This is an embedded html node by the way!
/// </pre>
///
/// ## Credits
/// - API doc style created by [Aras Pranckevičius](https://github.com/aras-p)
/// - Markdeep by [Morgan McGuire](https://casual-effects.com/markdeep/).