bixbite 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. data/LICENSE +20 -0
  2. data/README.markdown +49 -0
  3. data/VERSION +1 -0
  4. data/bin/bixbite +73 -0
  5. data/lib/bixbite.rb +13 -0
  6. data/lib/bixbite/command.rb +14 -0
  7. data/lib/bixbite/create.rb +76 -0
  8. data/template/Rakefile +25 -0
  9. data/template/assets/bixbite/Rakefile.rb +297 -0
  10. data/template/assets/naturaldocs/NaturalDocs/Config/Languages.txt +286 -0
  11. data/template/assets/naturaldocs/NaturalDocs/Config/Topics.txt +382 -0
  12. data/template/assets/naturaldocs/NaturalDocs/Help/customizinglanguages.html +52 -0
  13. data/template/assets/naturaldocs/NaturalDocs/Help/customizingtopics.html +74 -0
  14. data/template/assets/naturaldocs/NaturalDocs/Help/documenting.html +58 -0
  15. data/template/assets/naturaldocs/NaturalDocs/Help/documenting/reference.html +146 -0
  16. data/template/assets/naturaldocs/NaturalDocs/Help/documenting/walkthrough.html +180 -0
  17. data/template/assets/naturaldocs/NaturalDocs/Help/example/Default.css +528 -0
  18. data/template/assets/naturaldocs/NaturalDocs/Help/example/NaturalDocs.js +204 -0
  19. data/template/assets/naturaldocs/NaturalDocs/Help/examples.css +90 -0
  20. data/template/assets/naturaldocs/NaturalDocs/Help/images/header/background.png +0 -0
  21. data/template/assets/naturaldocs/NaturalDocs/Help/images/header/leftside.png +0 -0
  22. data/template/assets/naturaldocs/NaturalDocs/Help/images/header/logo.png +0 -0
  23. data/template/assets/naturaldocs/NaturalDocs/Help/images/header/overbody.png +0 -0
  24. data/template/assets/naturaldocs/NaturalDocs/Help/images/header/overbodybg.png +0 -0
  25. data/template/assets/naturaldocs/NaturalDocs/Help/images/header/overleftmargin.png +0 -0
  26. data/template/assets/naturaldocs/NaturalDocs/Help/images/header/overmenu.png +0 -0
  27. data/template/assets/naturaldocs/NaturalDocs/Help/images/header/overmenubg.png +0 -0
  28. data/template/assets/naturaldocs/NaturalDocs/Help/images/header/rightside.png +0 -0
  29. data/template/assets/naturaldocs/NaturalDocs/Help/images/logo.gif +0 -0
  30. data/template/assets/naturaldocs/NaturalDocs/Help/images/menu/about.png +0 -0
  31. data/template/assets/naturaldocs/NaturalDocs/Help/images/menu/background.png +0 -0
  32. data/template/assets/naturaldocs/NaturalDocs/Help/images/menu/bottomleft.png +0 -0
  33. data/template/assets/naturaldocs/NaturalDocs/Help/images/menu/bottomright.png +0 -0
  34. data/template/assets/naturaldocs/NaturalDocs/Help/images/menu/community.png +0 -0
  35. data/template/assets/naturaldocs/NaturalDocs/Help/images/menu/customizing.png +0 -0
  36. data/template/assets/naturaldocs/NaturalDocs/Help/images/menu/using.png +0 -0
  37. data/template/assets/naturaldocs/NaturalDocs/Help/index.html +9 -0
  38. data/template/assets/naturaldocs/NaturalDocs/Help/javascript/BrowserStyles.js +77 -0
  39. data/template/assets/naturaldocs/NaturalDocs/Help/javascript/PNGHandling.js +72 -0
  40. data/template/assets/naturaldocs/NaturalDocs/Help/keywords.html +38 -0
  41. data/template/assets/naturaldocs/NaturalDocs/Help/languages.html +32 -0
  42. data/template/assets/naturaldocs/NaturalDocs/Help/menu.html +79 -0
  43. data/template/assets/naturaldocs/NaturalDocs/Help/output.html +84 -0
  44. data/template/assets/naturaldocs/NaturalDocs/Help/running.html +40 -0
  45. data/template/assets/naturaldocs/NaturalDocs/Help/styles.css +290 -0
  46. data/template/assets/naturaldocs/NaturalDocs/Help/styles.html +52 -0
  47. data/template/assets/naturaldocs/NaturalDocs/Help/troubleshooting.html +18 -0
  48. data/template/assets/naturaldocs/NaturalDocs/Info/CSSGuide.txt +947 -0
  49. data/template/assets/naturaldocs/NaturalDocs/Info/File Parsing.txt +83 -0
  50. data/template/assets/naturaldocs/NaturalDocs/Info/HTMLTestCases.pm +269 -0
  51. data/template/assets/naturaldocs/NaturalDocs/Info/Languages.txt +107 -0
  52. data/template/assets/naturaldocs/NaturalDocs/Info/NDMarkup.txt +91 -0
  53. data/template/assets/naturaldocs/NaturalDocs/Info/Symbol Management.txt +59 -0
  54. data/template/assets/naturaldocs/NaturalDocs/Info/images/Logo.png +0 -0
  55. data/template/assets/naturaldocs/NaturalDocs/JavaScript/NaturalDocs.js +836 -0
  56. data/template/assets/naturaldocs/NaturalDocs/License-GPL.txt +341 -0
  57. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/BinaryFile.pm +294 -0
  58. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Builder.pm +280 -0
  59. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Builder/Base.pm +348 -0
  60. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Builder/FramedHTML.pm +345 -0
  61. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Builder/HTML.pm +398 -0
  62. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Builder/HTMLBase.pm +3693 -0
  63. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/ClassHierarchy.pm +860 -0
  64. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/ClassHierarchy/Class.pm +412 -0
  65. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/ClassHierarchy/File.pm +157 -0
  66. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/ConfigFile.pm +497 -0
  67. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Constants.pm +165 -0
  68. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/DefineMembers.pm +100 -0
  69. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Error.pm +305 -0
  70. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/File.pm +540 -0
  71. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/ImageReferenceTable.pm +383 -0
  72. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/ImageReferenceTable/Reference.pm +44 -0
  73. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/ImageReferenceTable/String.pm +110 -0
  74. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages.pm +1475 -0
  75. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/ActionScript.pm +1473 -0
  76. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Ada.pm +38 -0
  77. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Advanced.pm +828 -0
  78. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Advanced/Scope.pm +95 -0
  79. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Advanced/ScopeChange.pm +70 -0
  80. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Base.pm +832 -0
  81. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/CSharp.pm +1484 -0
  82. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/PLSQL.pm +319 -0
  83. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Pascal.pm +143 -0
  84. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Perl.pm +1370 -0
  85. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Prototype.pm +92 -0
  86. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Prototype/Parameter.pm +87 -0
  87. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Simple.pm +503 -0
  88. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Tcl.pm +219 -0
  89. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Menu.pm +3406 -0
  90. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Menu/Entry.pm +201 -0
  91. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/NDMarkup.pm +76 -0
  92. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Parser.pm +1331 -0
  93. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Parser/JavaDoc.pm +464 -0
  94. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Parser/Native.pm +1060 -0
  95. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Parser/ParsedTopic.pm +253 -0
  96. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Project.pm +1402 -0
  97. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Project/ImageFile.pm +160 -0
  98. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Project/SourceFile.pm +113 -0
  99. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/ReferenceString.pm +334 -0
  100. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Settings.pm +1418 -0
  101. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Settings/BuildTarget.pm +66 -0
  102. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SourceDB.pm +678 -0
  103. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SourceDB/Extension.pm +84 -0
  104. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SourceDB/File.pm +129 -0
  105. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SourceDB/Item.pm +201 -0
  106. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SourceDB/ItemDefinition.pm +45 -0
  107. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SourceDB/WatchedFileDefinitions.pm +159 -0
  108. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/StatusMessage.pm +102 -0
  109. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SymbolString.pm +212 -0
  110. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SymbolTable.pm +1984 -0
  111. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SymbolTable/File.pm +186 -0
  112. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SymbolTable/IndexElement.pm +522 -0
  113. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SymbolTable/Reference.pm +273 -0
  114. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SymbolTable/ReferenceTarget.pm +97 -0
  115. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SymbolTable/Symbol.pm +428 -0
  116. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SymbolTable/SymbolDefinition.pm +96 -0
  117. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Topics.pm +1319 -0
  118. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Topics/Type.pm +151 -0
  119. data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Version.pm +384 -0
  120. data/template/assets/naturaldocs/NaturalDocs/NaturalDocs +400 -0
  121. data/template/assets/naturaldocs/NaturalDocs/NaturalDocs.bat +17 -0
  122. data/template/assets/naturaldocs/NaturalDocs/Styles/Default.css +767 -0
  123. data/template/assets/naturaldocs/NaturalDocs/Styles/Roman.css +765 -0
  124. data/template/assets/naturaldocs/NaturalDocs/Styles/Small.css +763 -0
  125. data/template/assets/utilities/pngout +0 -0
  126. data/template/deploy/public_html/.htaccess +0 -0
  127. data/template/documentation/js/.htaccess +0 -0
  128. data/template/src/html/.htaccess +76 -0
  129. data/template/src/html/css/cmn/global.css +96 -0
  130. data/template/src/html/css/cmn/ie.css +15 -0
  131. data/template/src/html/css/cmn/ie6.css +15 -0
  132. data/template/src/html/images/cmn/.htaccess +0 -0
  133. data/template/src/html/images/tmp/.htaccess +0 -0
  134. data/template/src/html/includes/debug.inc +5 -0
  135. data/template/src/html/includes/footer.inc +52 -0
  136. data/template/src/html/includes/header.inc +61 -0
  137. data/template/src/html/includes/html.inc +3 -0
  138. data/template/src/html/includes/namespace.inc +19 -0
  139. data/template/src/html/includes/page.inc +151 -0
  140. data/template/src/html/index.html +35 -0
  141. data/template/src/html/js/cmn/bootstrap.js +74 -0
  142. data/template/src/html/js/cmn/global.js +142 -0
  143. data/template/src/html/js/cmn/lib/LAB.js +348 -0
  144. data/template/src/html/min/.htaccess +4 -0
  145. data/template/src/html/min/MinifyCLI.php +19 -0
  146. data/template/src/html/min/README.txt +132 -0
  147. data/template/src/html/min/builder/_index.js +242 -0
  148. data/template/src/html/min/builder/bm.js +36 -0
  149. data/template/src/html/min/builder/index.php +182 -0
  150. data/template/src/html/min/builder/ocCheck.php +36 -0
  151. data/template/src/html/min/builder/rewriteTest.js +1 -0
  152. data/template/src/html/min/config.php +187 -0
  153. data/template/src/html/min/groupsConfig.php +34 -0
  154. data/template/src/html/min/index.php +66 -0
  155. data/template/src/html/min/lib/FirePHP.php +1370 -0
  156. data/template/src/html/min/lib/HTTP/ConditionalGet.php +348 -0
  157. data/template/src/html/min/lib/HTTP/Encoder.php +326 -0
  158. data/template/src/html/min/lib/JSMin.php +314 -0
  159. data/template/src/html/min/lib/JSMinPlus.php +1872 -0
  160. data/template/src/html/min/lib/Minify.php +532 -0
  161. data/template/src/html/min/lib/Minify/Build.php +103 -0
  162. data/template/src/html/min/lib/Minify/CSS.php +83 -0
  163. data/template/src/html/min/lib/Minify/CSS/Compressor.php +250 -0
  164. data/template/src/html/min/lib/Minify/CSS/UriRewriter.php +270 -0
  165. data/template/src/html/min/lib/Minify/Cache/APC.php +130 -0
  166. data/template/src/html/min/lib/Minify/Cache/File.php +125 -0
  167. data/template/src/html/min/lib/Minify/Cache/Memcache.php +137 -0
  168. data/template/src/html/min/lib/Minify/ClosureCompiler.php +85 -0
  169. data/template/src/html/min/lib/Minify/CommentPreserver.php +90 -0
  170. data/template/src/html/min/lib/Minify/Controller/Base.php +202 -0
  171. data/template/src/html/min/lib/Minify/Controller/Files.php +78 -0
  172. data/template/src/html/min/lib/Minify/Controller/Groups.php +94 -0
  173. data/template/src/html/min/lib/Minify/Controller/MinApp.php +132 -0
  174. data/template/src/html/min/lib/Minify/Controller/Page.php +82 -0
  175. data/template/src/html/min/lib/Minify/Controller/Version1.php +118 -0
  176. data/template/src/html/min/lib/Minify/HTML.php +245 -0
  177. data/template/src/html/min/lib/Minify/ImportProcessor.php +157 -0
  178. data/template/src/html/min/lib/Minify/Lines.php +131 -0
  179. data/template/src/html/min/lib/Minify/Logger.php +45 -0
  180. data/template/src/html/min/lib/Minify/Packer.php +37 -0
  181. data/template/src/html/min/lib/Minify/Source.php +187 -0
  182. data/template/src/html/min/lib/Minify/YUICompressor.php +139 -0
  183. data/template/src/html/min/lib/Solar/Dir.php +199 -0
  184. data/template/src/html/min/lib/closure-compiler.jar +0 -0
  185. data/template/src/html/min/lib/yuicompressor-2.4.2.jar +0 -0
  186. data/template/src/html/min/utils.php +90 -0
  187. data/template/src/templates/css/template.css +7 -0
  188. data/template/src/templates/js/template.js +72 -0
  189. data/template/src/templates/template.html +18 -0
  190. data/template/src/yaml/config.yml +46 -0
  191. data/template/src/yaml/deploy.yml +35 -0
  192. data/test/bixbite_test.rb +7 -0
  193. data/test/test_helper.rb +10 -0
  194. metadata +278 -0
@@ -0,0 +1,38 @@
1
+ ###############################################################################
2
+ #
3
+ # Class: NaturalDocs::Languages::Ada
4
+ #
5
+ ###############################################################################
6
+ #
7
+ # A subclass to handle the language variations of Ada
8
+ #
9
+ ###############################################################################
10
+
11
+ # This file is part of Natural Docs, which is Copyright (C) 2003-2008 Greg Valure
12
+ # Natural Docs is licensed under the GPL
13
+
14
+ use strict;
15
+ use integer;
16
+
17
+ package NaturalDocs::Languages::Ada;
18
+
19
+ use base 'NaturalDocs::Languages::Simple';
20
+
21
+
22
+ #
23
+ # Function: ParseParameterLine
24
+ # Overridden because Ada uses Pascal-style parameters
25
+ #
26
+ sub ParseParameterLine #(...)
27
+ {
28
+ my ($self, @params) = @_;
29
+ return $self->SUPER::ParsePascalParameterLine(@params);
30
+ };
31
+
32
+ sub TypeBeforeParameter
33
+ {
34
+ return 0;
35
+ };
36
+
37
+
38
+ 1;
@@ -0,0 +1,828 @@
1
+ ###############################################################################
2
+ #
3
+ # Class: NaturalDocs::Languages::Advanced
4
+ #
5
+ ###############################################################################
6
+ #
7
+ # The base class for all languages that have full support in Natural Docs. Each one will have a custom parser capable
8
+ # of documenting undocumented aspects of the code.
9
+ #
10
+ ###############################################################################
11
+
12
+ # This file is part of Natural Docs, which is Copyright (C) 2003-2008 Greg Valure
13
+ # Natural Docs is licensed under the GPL
14
+
15
+ use strict;
16
+ use integer;
17
+
18
+ use NaturalDocs::Languages::Advanced::Scope;
19
+ use NaturalDocs::Languages::Advanced::ScopeChange;
20
+
21
+ package NaturalDocs::Languages::Advanced;
22
+
23
+ use base 'NaturalDocs::Languages::Base';
24
+
25
+
26
+ #############################################################################
27
+ # Group: Implementation
28
+
29
+ #
30
+ # Constants: Members
31
+ #
32
+ # The class is implemented as a blessed arrayref. The following constants are used as indexes.
33
+ #
34
+ # TOKENS - An arrayref of tokens used in all the <Parsing Functions>.
35
+ # SCOPE_STACK - An arrayref of <NaturalDocs::Languages::Advanced::Scope> objects serving as a scope stack for parsing.
36
+ # There will always be one available, with a symbol of undef, for the top level.
37
+ # SCOPE_RECORD - An arrayref of <NaturalDocs::Languages::Advanced::ScopeChange> objects, as generated by the scope
38
+ # stack. If there is more than one change per line, only the last is stored.
39
+ # AUTO_TOPICS - An arrayref of <NaturalDocs::Parser::ParsedTopics> generated automatically from the code.
40
+ #
41
+ use NaturalDocs::DefineMembers 'TOKENS', 'SCOPE_STACK', 'SCOPE_RECORD', 'AUTO_TOPICS';
42
+
43
+
44
+ #############################################################################
45
+ # Group: Functions
46
+
47
+ #
48
+ # Function: New
49
+ #
50
+ # Creates and returns a new object.
51
+ #
52
+ # Parameters:
53
+ #
54
+ # name - The name of the language.
55
+ #
56
+ sub New #(name)
57
+ {
58
+ my ($package, @parameters) = @_;
59
+
60
+ my $object = $package->SUPER::New(@parameters);
61
+ $object->[TOKENS] = undef;
62
+ $object->[SCOPE_STACK] = undef;
63
+ $object->[SCOPE_RECORD] = undef;
64
+
65
+ return $object;
66
+ };
67
+
68
+
69
+ # Function: Tokens
70
+ # Returns the tokens found by <ParseForCommentsAndTokens()>.
71
+ sub Tokens
72
+ { return $_[0]->[TOKENS]; };
73
+
74
+ # Function: SetTokens
75
+ # Replaces the tokens.
76
+ sub SetTokens #(tokens)
77
+ { $_[0]->[TOKENS] = $_[1]; };
78
+
79
+ # Function: ClearTokens
80
+ # Resets the token list. You may want to do this after parsing is over to save memory.
81
+ sub ClearTokens
82
+ { $_[0]->[TOKENS] = undef; };
83
+
84
+ # Function: AutoTopics
85
+ # Returns the arrayref of automatically generated topics, or undef if none.
86
+ sub AutoTopics
87
+ { return $_[0]->[AUTO_TOPICS]; };
88
+
89
+ # Function: AddAutoTopic
90
+ # Adds a <NaturalDocs::Parser::ParsedTopic> to <AutoTopics()>.
91
+ sub AddAutoTopic #(topic)
92
+ {
93
+ my ($self, $topic) = @_;
94
+ if (!defined $self->[AUTO_TOPICS])
95
+ { $self->[AUTO_TOPICS] = [ ]; };
96
+ push @{$self->[AUTO_TOPICS]}, $topic;
97
+ };
98
+
99
+ # Function: ClearAutoTopics
100
+ # Resets the automatic topic list. Not necessary if you call <ParseForCommentsAndTokens()>.
101
+ sub ClearAutoTopics
102
+ { $_[0]->[AUTO_TOPICS] = undef; };
103
+
104
+ # Function: ScopeRecord
105
+ # Returns an arrayref of <NaturalDocs::Languages::Advanced::ScopeChange> objects describing how and when the scope
106
+ # changed thoughout the file. There will always be at least one entry, which will be for line 1 and undef as the scope.
107
+ sub ScopeRecord
108
+ { return $_[0]->[SCOPE_RECORD]; };
109
+
110
+
111
+
112
+ ###############################################################################
113
+ #
114
+ # Group: Parsing Functions
115
+ #
116
+ # These functions are good general language building blocks. Use them to create your language-specific parser.
117
+ #
118
+ # All functions work on <Tokens()> and assume it is set by <ParseForCommentsAndTokens()>.
119
+ #
120
+
121
+
122
+ #
123
+ # Function: ParseForCommentsAndTokens
124
+ #
125
+ # Loads the passed file, sends all appropriate comments to <NaturalDocs::Parser->OnComment()>, and breaks the rest into
126
+ # an arrayref of tokens. Tokens are defined as
127
+ #
128
+ # - All consecutive alphanumeric and underscore characters.
129
+ # - All consecutive whitespace.
130
+ # - A single line break. It will always be "\n"; you don't have to worry about platform differences.
131
+ # - A single character not included above, which is usually a symbol. Multiple consecutive ones each get their own token.
132
+ #
133
+ # The result will be placed in <Tokens()>.
134
+ #
135
+ # Parameters:
136
+ #
137
+ # sourceFile - The source <FileName> to load and parse.
138
+ # lineCommentSymbols - An arrayref of symbols that designate line comments, or undef if none.
139
+ # blockCommentSymbols - An arrayref of symbol pairs that designate multiline comments, or undef if none. Symbol pairs are
140
+ # designated as two consecutive array entries, the opening symbol appearing first.
141
+ # javadocLineCommentSymbols - An arrayref of symbols that designate the start of a JavaDoc comment, or undef if none.
142
+ # javadocBlockCommentSymbols - An arrayref of symbol pairs that designate multiline JavaDoc comments, or undef if none.
143
+ #
144
+ # Notes:
145
+ #
146
+ # - This function automatically calls <ClearAutoTopics()> and <ClearScopeStack()>. You only need to call those functions
147
+ # manually if you override this one.
148
+ # - To save parsing time, all comment lines sent to <NaturalDocs::Parser->OnComment()> will be replaced with blank lines
149
+ # in <Tokens()>. It's all the same to most languages.
150
+ #
151
+ sub ParseForCommentsAndTokens #(FileName sourceFile, string[] lineCommentSymbols, string[] blockCommentSymbols, string[] javadocLineCommentSymbols, string[] javadocBlockCommentSymbols)
152
+ {
153
+ my ($self, $sourceFile, $lineCommentSymbols, $blockCommentSymbols,
154
+ $javadocLineCommentSymbols, $javadocBlockCommentSymbols) = @_;
155
+
156
+ open(SOURCEFILEHANDLE, '<' . $sourceFile)
157
+ or die "Couldn't open input file " . $sourceFile . "\n";
158
+
159
+ my $tokens = [ ];
160
+ $self->SetTokens($tokens);
161
+
162
+ # For convenience.
163
+ $self->ClearAutoTopics();
164
+ $self->ClearScopeStack();
165
+
166
+
167
+ # Load and preprocess the file
168
+
169
+ my @lines;
170
+ my $line = <SOURCEFILEHANDLE>;
171
+
172
+ # On the very first line, remove a Unicode BOM if present. Information on it available at:
173
+ # http://www.unicode.org/faq/utf_bom.html#BOM
174
+ $line =~ s/^\xEF\xBB\xBF//;
175
+
176
+ while (defined $line)
177
+ {
178
+ ::XChomp(\$line);
179
+ push @lines, $line;
180
+
181
+ $line = <SOURCEFILEHANDLE>;
182
+ };
183
+
184
+ close(SOURCEFILEHANDLE);
185
+
186
+ $self->PreprocessFile(\@lines);
187
+
188
+
189
+ # Go through the file
190
+
191
+ my $lineIndex = 0;
192
+
193
+ while ($lineIndex < scalar @lines)
194
+ {
195
+ $line = $lines[$lineIndex];
196
+
197
+ my @commentLines;
198
+ my $commentLineNumber;
199
+ my $isJavaDoc;
200
+ my $closingSymbol;
201
+
202
+
203
+ # Retrieve single line comments. This leaves $lineIndex at the next line.
204
+
205
+ if ( ($isJavaDoc = $self->StripOpeningJavaDocSymbols(\$line, $javadocLineCommentSymbols)) ||
206
+ $self->StripOpeningSymbols(\$line, $lineCommentSymbols))
207
+ {
208
+ $commentLineNumber = $lineIndex + 1;
209
+
210
+ do
211
+ {
212
+ push @commentLines, $line;
213
+ push @$tokens, "\n";
214
+
215
+ $lineIndex++;
216
+
217
+ if ($lineIndex >= scalar @lines)
218
+ { goto EndDo; };
219
+
220
+ $line = $lines[$lineIndex];
221
+ }
222
+ while ($self->StripOpeningSymbols(\$line, $lineCommentSymbols));
223
+
224
+ EndDo: # I hate Perl sometimes.
225
+ }
226
+
227
+
228
+ # Retrieve multiline comments. This leaves $lineIndex at the next line.
229
+
230
+ elsif ( ($isJavaDoc = $self->StripOpeningJavaDocBlockSymbols(\$line, $javadocBlockCommentSymbols)) ||
231
+ ($closingSymbol = $self->StripOpeningBlockSymbols(\$line, $blockCommentSymbols)) )
232
+ {
233
+ $commentLineNumber = $lineIndex + 1;
234
+
235
+ if ($isJavaDoc)
236
+ { $closingSymbol = $isJavaDoc; };
237
+
238
+ # Note that it is possible for a multiline comment to start correctly but not end so. We want those comments to stay in
239
+ # the code. For example, look at this prototype with this splint annotation:
240
+ #
241
+ # int get_array(integer_t id,
242
+ # /*@out@*/ array_t array);
243
+ #
244
+ # The annotation starts correctly but doesn't end so because it is followed by code on the same line.
245
+
246
+ my ($lineRemainder, $isMultiLine);
247
+
248
+ for (;;)
249
+ {
250
+ $lineRemainder = $self->StripClosingSymbol(\$line, $closingSymbol);
251
+
252
+ push @commentLines, $line;
253
+
254
+ # If we found an end comment symbol...
255
+ if (defined $lineRemainder)
256
+ { last; };
257
+
258
+ push @$tokens, "\n";
259
+ $lineIndex++;
260
+ $isMultiLine = 1;
261
+
262
+ if ($lineIndex >= scalar @lines)
263
+ { last; };
264
+
265
+ $line = $lines[$lineIndex];
266
+ };
267
+
268
+ if ($lineRemainder !~ /^[ \t]*$/)
269
+ {
270
+ # If there was something past the closing symbol this wasn't an acceptable comment.
271
+
272
+ if ($isMultiLine)
273
+ { $self->TokenizeLine($lineRemainder); }
274
+ else
275
+ {
276
+ # We go back to the original line if it wasn't a multiline comment because we want the comment to stay in the
277
+ # code. Otherwise the /*@out@*/ from the example would be removed.
278
+ $self->TokenizeLine($lines[$lineIndex]);
279
+ };
280
+
281
+ @commentLines = ( );
282
+ }
283
+ else
284
+ {
285
+ push @$tokens, "\n";
286
+ };
287
+
288
+ $lineIndex++;
289
+ }
290
+
291
+
292
+ # Otherwise just add it to the code.
293
+
294
+ else
295
+ {
296
+ $self->TokenizeLine($line);
297
+ $lineIndex++;
298
+ };
299
+
300
+
301
+ # If there were comments, send them to Parser->OnComment().
302
+
303
+ if (scalar @commentLines)
304
+ {
305
+ NaturalDocs::Parser->OnComment(\@commentLines, $commentLineNumber, $isJavaDoc);
306
+ @commentLines = ( );
307
+ $isJavaDoc = undef;
308
+ };
309
+
310
+ # $lineIndex was incremented by the individual code paths above.
311
+
312
+ }; # while ($lineIndex < scalar @lines)
313
+ };
314
+
315
+
316
+ #
317
+ # Function: PreprocessFile
318
+ #
319
+ # An overridable function if you'd like to preprocess the file before it goes into <ParseForCommentsAndTokens()>.
320
+ #
321
+ # Parameters:
322
+ #
323
+ # lines - An arrayref to the file's lines. Each line has its line break stripped off, but is otherwise untouched.
324
+ #
325
+ sub PreprocessFile #(lines)
326
+ {
327
+ };
328
+
329
+
330
+ #
331
+ # Function: TokenizeLine
332
+ #
333
+ # Converts the passed line to tokens as described in <ParseForCommentsAndTokens> and adds them to <Tokens()>. Also
334
+ # adds a line break token after it.
335
+ #
336
+ sub TokenizeLine #(line)
337
+ {
338
+ my ($self, $line) = @_;
339
+ push @{$self->Tokens()}, $line =~ /(\w+|[ \t]+|.)/g, "\n";
340
+ };
341
+
342
+
343
+ #
344
+ # Function: TryToSkipString
345
+ #
346
+ # If the position is on a string delimiter, moves the position to the token following the closing delimiter, or past the end of the
347
+ # tokens if there is none. Assumes all other characters are allowed in the string, the delimiter itself is allowed if it's preceded by
348
+ # a backslash, and line breaks are allowed in the string.
349
+ #
350
+ # Parameters:
351
+ #
352
+ # indexRef - A reference to the position's index into <Tokens()>.
353
+ # lineNumberRef - A reference to the position's line number.
354
+ # openingDelimiter - The opening string delimiter, such as a quote or an apostrophe.
355
+ # closingDelimiter - The closing string delimiter, if different. If not defined, assumes the same as openingDelimiter.
356
+ # startContentIndexRef - A reference to a variable in which to store the index of the first token of the string's content.
357
+ # May be undef.
358
+ # endContentIndexRef - A reference to a variable in which to store the index of the end of the string's content, which is one
359
+ # past the last index of content. May be undef.
360
+ #
361
+ # Returns:
362
+ #
363
+ # Whether the position was on the passed delimiter or not. The index, line number, and content index ref variables will be
364
+ # updated only if true.
365
+ #
366
+ sub TryToSkipString #(indexRef, lineNumberRef, openingDelimiter, closingDelimiter, startContentIndexRef, endContentIndexRef)
367
+ {
368
+ my ($self, $index, $lineNumber, $openingDelimiter, $closingDelimiter, $startContentIndexRef, $endContentIndexRef) = @_;
369
+ my $tokens = $self->Tokens();
370
+
371
+ if (!defined $closingDelimiter)
372
+ { $closingDelimiter = $openingDelimiter; };
373
+
374
+ if ($tokens->[$$index] ne $openingDelimiter)
375
+ { return undef; };
376
+
377
+
378
+ $$index++;
379
+ if (defined $startContentIndexRef)
380
+ { $$startContentIndexRef = $$index; };
381
+
382
+ while ($$index < scalar @$tokens)
383
+ {
384
+ if ($tokens->[$$index] eq "\\")
385
+ {
386
+ # Skip the token after it.
387
+ $$index += 2;
388
+ }
389
+ elsif ($tokens->[$$index] eq "\n")
390
+ {
391
+ $$lineNumber++;
392
+ $$index++;
393
+ }
394
+ elsif ($tokens->[$$index] eq $closingDelimiter)
395
+ {
396
+ if (defined $endContentIndexRef)
397
+ { $$endContentIndexRef = $$index; };
398
+
399
+ $$index++;
400
+ last;
401
+ }
402
+ else
403
+ {
404
+ $$index++;
405
+ };
406
+ };
407
+
408
+ if ($$index >= scalar @$tokens && defined $endContentIndexRef)
409
+ { $$endContentIndexRef = scalar @$tokens; };
410
+
411
+ return 1;
412
+ };
413
+
414
+
415
+ #
416
+ # Function: SkipRestOfLine
417
+ #
418
+ # Moves the position to the token following the next line break, or past the end of the tokens array if there is none. Useful for
419
+ # line comments.
420
+ #
421
+ # Note that it skips blindly. It assumes there cannot be anything of interest, such as a string delimiter, between the position
422
+ # and the end of the line.
423
+ #
424
+ # Parameters:
425
+ #
426
+ # indexRef - A reference to the position's index into <Tokens()>.
427
+ # lineNumberRef - A reference to the position's line number.
428
+
429
+ sub SkipRestOfLine #(indexRef, lineNumberRef)
430
+ {
431
+ my ($self, $index, $lineNumber) = @_;
432
+ my $tokens = $self->Tokens();
433
+
434
+ while ($$index < scalar @$tokens)
435
+ {
436
+ if ($tokens->[$$index] eq "\n")
437
+ {
438
+ $$lineNumber++;
439
+ $$index++;
440
+ last;
441
+ }
442
+ else
443
+ {
444
+ $$index++;
445
+ };
446
+ };
447
+ };
448
+
449
+
450
+ #
451
+ # Function: SkipUntilAfter
452
+ #
453
+ # Moves the position to the token following the next occurance of a particular token sequence, or past the end of the tokens
454
+ # array if it never occurs. Useful for multiline comments.
455
+ #
456
+ # Note that it skips blindly. It assumes there cannot be anything of interest, such as a string delimiter, between the position
457
+ # and the end of the line.
458
+ #
459
+ # Parameters:
460
+ #
461
+ # indexRef - A reference to the position's index.
462
+ # lineNumberRef - A reference to the position's line number.
463
+ # token - A token that must be matched. Can be specified multiple times to match a sequence of tokens.
464
+ #
465
+ sub SkipUntilAfter #(indexRef, lineNumberRef, token, token, ...)
466
+ {
467
+ my ($self, $index, $lineNumber, @target) = @_;
468
+ my $tokens = $self->Tokens();
469
+
470
+ while ($$index < scalar @$tokens)
471
+ {
472
+ if ($tokens->[$$index] eq $target[0] && ($$index + scalar @target) <= scalar @$tokens)
473
+ {
474
+ my $match = 1;
475
+
476
+ for (my $i = 1; $i < scalar @target; $i++)
477
+ {
478
+ if ($tokens->[$$index+$i] ne $target[$i])
479
+ {
480
+ $match = 0;
481
+ last;
482
+ };
483
+ };
484
+
485
+ if ($match)
486
+ {
487
+ $$index += scalar @target;
488
+ return;
489
+ };
490
+ };
491
+
492
+ if ($tokens->[$$index] eq "\n")
493
+ {
494
+ $$lineNumber++;
495
+ $$index++;
496
+ }
497
+ else
498
+ {
499
+ $$index++;
500
+ };
501
+ };
502
+ };
503
+
504
+
505
+ #
506
+ # Function: IsFirstLineToken
507
+ #
508
+ # Returns whether the position is at the first token of a line, not including whitespace.
509
+ #
510
+ # Parameters:
511
+ #
512
+ # index - The index of the position.
513
+ #
514
+ sub IsFirstLineToken #(index)
515
+ {
516
+ my ($self, $index) = @_;
517
+ my $tokens = $self->Tokens();
518
+
519
+ if ($index == 0)
520
+ { return 1; };
521
+
522
+ $index--;
523
+
524
+ if ($tokens->[$index] =~ /^[ \t]/)
525
+ { $index--; };
526
+
527
+ if ($index <= 0 || $tokens->[$index] eq "\n")
528
+ { return 1; }
529
+ else
530
+ { return undef; };
531
+ };
532
+
533
+
534
+ #
535
+ # Function: IsLastLineToken
536
+ #
537
+ # Returns whether the position is at the last token of a line, not including whitespace.
538
+ #
539
+ # Parameters:
540
+ #
541
+ # index - The index of the position.
542
+ #
543
+ sub IsLastLineToken #(index)
544
+ {
545
+ my ($self, $index) = @_;
546
+ my $tokens = $self->Tokens();
547
+
548
+ do
549
+ { $index++; }
550
+ while ($index < scalar @$tokens && $tokens->[$index] =~ /^[ \t]/);
551
+
552
+ if ($index >= scalar @$tokens || $tokens->[$index] eq "\n")
553
+ { return 1; }
554
+ else
555
+ { return undef; };
556
+ };
557
+
558
+
559
+ #
560
+ # Function: IsAtSequence
561
+ #
562
+ # Returns whether the position is at a sequence of tokens.
563
+ #
564
+ # Parameters:
565
+ #
566
+ # index - The index of the position.
567
+ # token - A token to match. Specify multiple times to specify the sequence.
568
+ #
569
+ sub IsAtSequence #(index, token, token, token ...)
570
+ {
571
+ my ($self, $index, @target) = @_;
572
+ my $tokens = $self->Tokens();
573
+
574
+ if ($index + scalar @target > scalar @$tokens)
575
+ { return undef; };
576
+
577
+ for (my $i = 0; $i < scalar @target; $i++)
578
+ {
579
+ if ($tokens->[$index + $i] ne $target[$i])
580
+ { return undef; };
581
+ };
582
+
583
+ return 1;
584
+ };
585
+
586
+
587
+ #
588
+ # Function: IsBackslashed
589
+ #
590
+ # Returns whether the position is after a backslash.
591
+ #
592
+ # Parameters:
593
+ #
594
+ # index - The index of the postition.
595
+ #
596
+ sub IsBackslashed #(index)
597
+ {
598
+ my ($self, $index) = @_;
599
+ my $tokens = $self->Tokens();
600
+
601
+ if ($index > 0 && $tokens->[$index - 1] eq "\\")
602
+ { return 1; }
603
+ else
604
+ { return undef; };
605
+ };
606
+
607
+
608
+
609
+ ###############################################################################
610
+ #
611
+ # Group: Scope Functions
612
+ #
613
+ # These functions provide a nice scope stack implementation for language-specific parsers to use. The default implementation
614
+ # makes the following assumptions.
615
+ #
616
+ # - Packages completely replace one another, rather than concatenating. You need to concatenate manually if that's the
617
+ # behavior.
618
+ #
619
+ # - Packages inherit, so if a scope level doesn't set its own, the package is the same as the parent scope's.
620
+ #
621
+
622
+
623
+ #
624
+ # Function: ClearScopeStack
625
+ #
626
+ # Clears the scope stack for a new file. Not necessary if you call <ParseForCommentsAndTokens()>.
627
+ #
628
+ sub ClearScopeStack
629
+ {
630
+ my ($self) = @_;
631
+ $self->[SCOPE_STACK] = [ NaturalDocs::Languages::Advanced::Scope->New(undef, undef) ];
632
+ $self->[SCOPE_RECORD] = [ NaturalDocs::Languages::Advanced::ScopeChange->New(undef, 1) ];
633
+ };
634
+
635
+
636
+ #
637
+ # Function: StartScope
638
+ #
639
+ # Records a new scope level.
640
+ #
641
+ # Parameters:
642
+ #
643
+ # closingSymbol - The closing symbol of the scope.
644
+ # lineNumber - The line number where the scope begins.
645
+ # package - The package <SymbolString> of the scope. Undef means no change.
646
+ #
647
+ sub StartScope #(closingSymbol, lineNumber, package)
648
+ {
649
+ my ($self, $closingSymbol, $lineNumber, $package) = @_;
650
+
651
+ push @{$self->[SCOPE_STACK]},
652
+ NaturalDocs::Languages::Advanced::Scope->New($closingSymbol, $package, $self->CurrentUsing());
653
+
654
+ $self->AddToScopeRecord($self->CurrentScope(), $lineNumber);
655
+ };
656
+
657
+
658
+ #
659
+ # Function: EndScope
660
+ #
661
+ # Records the end of the current scope level. Note that this is blind; you need to manually check <ClosingScopeSymbol()> if
662
+ # you need to determine if it is correct to do so.
663
+ #
664
+ # Parameters:
665
+ #
666
+ # lineNumber - The line number where the scope ends.
667
+ #
668
+ sub EndScope #(lineNumber)
669
+ {
670
+ my ($self, $lineNumber) = @_;
671
+
672
+ if (scalar @{$self->[SCOPE_STACK]} > 1)
673
+ { pop @{$self->[SCOPE_STACK]}; };
674
+
675
+ $self->AddToScopeRecord($self->CurrentScope(), $lineNumber);
676
+ };
677
+
678
+
679
+ #
680
+ # Function: ClosingScopeSymbol
681
+ #
682
+ # Returns the symbol that ends the current scope level, or undef if we are at the top level.
683
+ #
684
+ sub ClosingScopeSymbol
685
+ {
686
+ my ($self) = @_;
687
+ return $self->[SCOPE_STACK]->[-1]->ClosingSymbol();
688
+ };
689
+
690
+
691
+ #
692
+ # Function: CurrentScope
693
+ #
694
+ # Returns the current calculated scope, or undef if global. The default implementation just returns <CurrentPackage()>. This
695
+ # is a separate function because C++ may need to track namespaces and classes separately, and so the current scope would
696
+ # be a concatenation of them.
697
+ #
698
+ sub CurrentScope
699
+ {
700
+ return $_[0]->CurrentPackage();
701
+ };
702
+
703
+
704
+ #
705
+ # Function: CurrentPackage
706
+ #
707
+ # Returns the current calculated package or class, or undef if none.
708
+ #
709
+ sub CurrentPackage
710
+ {
711
+ my ($self) = @_;
712
+
713
+ my $package;
714
+
715
+ for (my $index = scalar @{$self->[SCOPE_STACK]} - 1; $index >= 0 && !defined $package; $index--)
716
+ {
717
+ $package = $self->[SCOPE_STACK]->[$index]->Package();
718
+ };
719
+
720
+ return $package;
721
+ };
722
+
723
+
724
+ #
725
+ # Function: SetPackage
726
+ #
727
+ # Sets the package for the current scope level.
728
+ #
729
+ # Parameters:
730
+ #
731
+ # package - The new package <SymbolString>.
732
+ # lineNumber - The line number the new package starts on.
733
+ #
734
+ sub SetPackage #(package, lineNumber)
735
+ {
736
+ my ($self, $package, $lineNumber) = @_;
737
+ $self->[SCOPE_STACK]->[-1]->SetPackage($package);
738
+
739
+ $self->AddToScopeRecord($self->CurrentScope(), $lineNumber);
740
+ };
741
+
742
+
743
+ #
744
+ # Function: CurrentUsing
745
+ #
746
+ # Returns the current calculated arrayref of <SymbolStrings> from Using statements, or undef if none.
747
+ #
748
+ sub CurrentUsing
749
+ {
750
+ my ($self) = @_;
751
+ return $self->[SCOPE_STACK]->[-1]->Using();
752
+ };
753
+
754
+
755
+ #
756
+ # Function: AddUsing
757
+ #
758
+ # Adds a Using <SymbolString> to the current scope.
759
+ #
760
+ sub AddUsing #(using)
761
+ {
762
+ my ($self, $using) = @_;
763
+ $self->[SCOPE_STACK]->[-1]->AddUsing($using);
764
+ };
765
+
766
+
767
+
768
+ ###############################################################################
769
+ # Group: Support Functions
770
+
771
+
772
+ #
773
+ # Function: AddToScopeRecord
774
+ #
775
+ # Adds a change to the scope record, condensing unnecessary entries.
776
+ #
777
+ # Parameters:
778
+ #
779
+ # newScope - What the scope <SymbolString> changed to.
780
+ # lineNumber - Where the scope changed.
781
+ #
782
+ sub AddToScopeRecord #(newScope, lineNumber)
783
+ {
784
+ my ($self, $scope, $lineNumber) = @_;
785
+ my $scopeRecord = $self->ScopeRecord();
786
+
787
+ if ($scope ne $scopeRecord->[-1]->Scope())
788
+ {
789
+ if ($scopeRecord->[-1]->LineNumber() == $lineNumber)
790
+ { $scopeRecord->[-1]->SetScope($scope); }
791
+ else
792
+ { push @$scopeRecord, NaturalDocs::Languages::Advanced::ScopeChange->New($scope, $lineNumber); };
793
+ };
794
+ };
795
+
796
+
797
+ #
798
+ # Function: CreateString
799
+ #
800
+ # Converts the specified tokens into a string and returns it.
801
+ #
802
+ # Parameters:
803
+ #
804
+ # startIndex - The starting index to convert.
805
+ # endIndex - The ending index, which is *not inclusive*.
806
+ #
807
+ # Returns:
808
+ #
809
+ # The string.
810
+ #
811
+ sub CreateString #(startIndex, endIndex)
812
+ {
813
+ my ($self, $startIndex, $endIndex) = @_;
814
+ my $tokens = $self->Tokens();
815
+
816
+ my $string;
817
+
818
+ while ($startIndex < $endIndex && $startIndex < scalar @$tokens)
819
+ {
820
+ $string .= $tokens->[$startIndex];
821
+ $startIndex++;
822
+ };
823
+
824
+ return $string;
825
+ };
826
+
827
+
828
+ 1;