stddoc.c 4.8 KB

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