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,95 @@
1
+ ###############################################################################
2
+ #
3
+ # Class: NaturalDocs::Languages::Advanced::Scope
4
+ #
5
+ ###############################################################################
6
+ #
7
+ # A class used to store a scope level.
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::Advanced::Scope;
18
+
19
+ #
20
+ # Constants: Implementation
21
+ #
22
+ # The object is implemented as a blessed arrayref. The constants below are used as indexes.
23
+ #
24
+ # CLOSING_SYMBOL - The closing symbol character of the scope.
25
+ # PACKAGE - The package <SymbolString> of the scope.
26
+ # USING - An arrayref of <SymbolStrings> for using statements, or undef if none.
27
+ #
28
+ use NaturalDocs::DefineMembers 'CLOSING_SYMBOL', 'PACKAGE', 'USING';
29
+ # Dependency: New() depends on the order of these constants as well as that there is no inherited members.
30
+
31
+
32
+ #
33
+ # Function: New
34
+ #
35
+ # Creates and returns a new object.
36
+ #
37
+ # Parameters:
38
+ #
39
+ # closingSymbol - The closing symbol character of the scope.
40
+ # package - The package <SymbolString> of the scope.
41
+ # using - An arrayref of using <SymbolStrings>, or undef if none. The contents of the array will be duplicated.
42
+ #
43
+ # If package is set to undef, it is assumed that it inherits the value of the previous scope on the stack.
44
+ #
45
+ sub New #(closingSymbol, package, using)
46
+ {
47
+ # Dependency: This depends on the order of the parameters matching the constants, and that there are no inherited
48
+ # members.
49
+ my $package = shift;
50
+
51
+ my $object = [ @_ ];
52
+ bless $object, $package;
53
+
54
+ if (defined $object->[USING])
55
+ { $object->[USING] = [ @{$object->[USING]} ]; };
56
+
57
+ return $object;
58
+ };
59
+
60
+
61
+ # Function: ClosingSymbol
62
+ # Returns the closing symbol character of the scope.
63
+ sub ClosingSymbol
64
+ { return $_[0]->[CLOSING_SYMBOL]; };
65
+
66
+ # Function: Package
67
+ # Returns the package <SymbolString> of the scope, or undef if none.
68
+ sub Package
69
+ { return $_[0]->[PACKAGE]; };
70
+
71
+ # Function: SetPackage
72
+ # Sets the package <SymbolString> of the scope.
73
+ sub SetPackage #(package)
74
+ { $_[0]->[PACKAGE] = $_[1]; };
75
+
76
+ # Function: Using
77
+ # Returns an arrayref of <SymbolStrings> for using statements, or undef if none
78
+ sub Using
79
+ { return $_[0]->[USING]; };
80
+
81
+ # Function: AddUsing
82
+ # Adds a <SymbolString> to the <Using()> array.
83
+ sub AddUsing #(using)
84
+ {
85
+ my ($self, $using) = @_;
86
+
87
+ if (!defined $self->[USING])
88
+ { $self->[USING] = [ ]; };
89
+
90
+ push @{$self->[USING]}, $using;
91
+ };
92
+
93
+
94
+
95
+ 1;
@@ -0,0 +1,70 @@
1
+ ###############################################################################
2
+ #
3
+ # Class: NaturalDocs::Languages::Advanced::ScopeChange
4
+ #
5
+ ###############################################################################
6
+ #
7
+ # A class used to store a scope change.
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::Advanced::ScopeChange;
18
+
19
+ #
20
+ # Constants: Implementation
21
+ #
22
+ # The object is implemented as a blessed arrayref. The constants below are used as indexes.
23
+ #
24
+ # SCOPE - The new scope <SymbolString>.
25
+ # LINE_NUMBER - The line number of the change.
26
+ #
27
+ use NaturalDocs::DefineMembers 'SCOPE', 'LINE_NUMBER';
28
+ # Dependency: New() depends on the order of these constants as well as that there is no inherited members.
29
+
30
+
31
+ #
32
+ # Function: New
33
+ #
34
+ # Creates and returns a new object.
35
+ #
36
+ # Parameters:
37
+ #
38
+ # scope - The <SymbolString> the scope was changed to.
39
+ # lineNumber - What line it occurred on.
40
+ #
41
+ sub New #(scope, lineNumber)
42
+ {
43
+ # Dependency: This depends on the order of the parameters matching the constants, and that there are no inherited
44
+ # members.
45
+ my $self = shift;
46
+
47
+ my $object = [ @_ ];
48
+ bless $object, $self;
49
+
50
+ return $object;
51
+ };
52
+
53
+
54
+ # Function: Scope
55
+ # Returns the <SymbolString> the scope was changed to.
56
+ sub Scope
57
+ { return $_[0]->[SCOPE]; };
58
+
59
+ # Function: SetScope
60
+ # Replaces the <SymbolString> the scope was changed to.
61
+ sub SetScope #(scope)
62
+ { $_[0]->[SCOPE] = $_[1]; };
63
+
64
+ # Function: LineNumber
65
+ # Returns the line number of the change.
66
+ sub LineNumber
67
+ { return $_[0]->[LINE_NUMBER]; };
68
+
69
+
70
+ 1;
@@ -0,0 +1,832 @@
1
+ ###############################################################################
2
+ #
3
+ # Class: NaturalDocs::Languages::Base
4
+ #
5
+ ###############################################################################
6
+ #
7
+ # A base class for all programming language parsers.
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::Base;
18
+
19
+ use NaturalDocs::DefineMembers 'NAME', 'Name()',
20
+ 'EXTENSIONS', 'Extensions()', 'SetExtensions() duparrayref',
21
+ 'SHEBANG_STRINGS', 'ShebangStrings()', 'SetShebangStrings() duparrayref',
22
+ 'IGNORED_PREFIXES',
23
+ 'ENUM_VALUES';
24
+
25
+ use base 'Exporter';
26
+ our @EXPORT = ('ENUM_GLOBAL', 'ENUM_UNDER_TYPE', 'ENUM_UNDER_PARENT');
27
+
28
+
29
+ #
30
+ # Constants: EnumValuesType
31
+ #
32
+ # How enum values are handled in the language.
33
+ #
34
+ # ENUM_GLOBAL - Values are always global and thus 'value'.
35
+ # ENUM_UNDER_TYPE - Values are under the type in the hierarchy, and thus 'package.enum.value'.
36
+ # ENUM_UNDER_PARENT - Values are under the parent in the hierarchy, putting them on the same level as the enum itself. Thus
37
+ # 'package.value'.
38
+ #
39
+ use constant ENUM_GLOBAL => 1;
40
+ use constant ENUM_UNDER_TYPE => 2;
41
+ use constant ENUM_UNDER_PARENT => 3;
42
+
43
+
44
+ #
45
+ # Handle: SOURCEFILEHANDLE
46
+ #
47
+ # The handle of the source file currently being parsed.
48
+ #
49
+
50
+
51
+ #
52
+ # Function: New
53
+ #
54
+ # Creates and returns a new object.
55
+ #
56
+ # Parameters:
57
+ #
58
+ # name - The name of the language.
59
+ #
60
+ sub New #(name)
61
+ {
62
+ my ($selfPackage, $name) = @_;
63
+
64
+ my $object = [ ];
65
+
66
+ $object->[NAME] = $name;
67
+
68
+ bless $object, $selfPackage;
69
+ return $object;
70
+ };
71
+
72
+
73
+ #
74
+ # Functions: Members
75
+ #
76
+ # Name - Returns the language's name.
77
+ # Extensions - Returns an arrayref of the language's file extensions, or undef if none.
78
+ # SetExtensions - Replaces the arrayref of the language's file extensions.
79
+ # ShebangStrings - Returns an arrayref of the language's shebang strings, or undef if none.
80
+ # SetShebangStrings - Replaces the arrayref of the language's shebang strings.
81
+ #
82
+
83
+ #
84
+ # Function: PackageSeparator
85
+ # Returns the language's package separator string.
86
+ #
87
+ sub PackageSeparator
88
+ { return '.'; };
89
+
90
+ #
91
+ # Function: PackageSeparatorWasSet
92
+ # Returns whether the language's package separator string was ever changed from the default.
93
+ #
94
+ sub PackageSeparatorWasSet
95
+ { return 0; };
96
+
97
+
98
+ #
99
+ # Function: EnumValues
100
+ # Returns the <EnumValuesType> that describes how the language handles enums.
101
+ #
102
+ sub EnumValues
103
+ { return ENUM_GLOBAL; };
104
+
105
+
106
+ #
107
+ # Function: IgnoredPrefixesFor
108
+ #
109
+ # Returns an arrayref of ignored prefixes for the passed <TopicType>, or undef if none. The array is sorted so that the longest
110
+ # prefixes are first.
111
+ #
112
+ sub IgnoredPrefixesFor #(type)
113
+ {
114
+ my ($self, $type) = @_;
115
+
116
+ if (defined $self->[IGNORED_PREFIXES])
117
+ { return $self->[IGNORED_PREFIXES]->{$type}; }
118
+ else
119
+ { return undef; };
120
+ };
121
+
122
+
123
+ #
124
+ # Function: SetIgnoredPrefixesFor
125
+ #
126
+ # Replaces the arrayref of ignored prefixes for the passed <TopicType>.
127
+ #
128
+ sub SetIgnoredPrefixesFor #(type, prefixes)
129
+ {
130
+ my ($self, $type, $prefixesRef) = @_;
131
+
132
+ if (!defined $self->[IGNORED_PREFIXES])
133
+ { $self->[IGNORED_PREFIXES] = { }; };
134
+
135
+ if (!defined $prefixesRef)
136
+ { delete $self->[IGNORED_PREFIXES]->{$type}; }
137
+ else
138
+ {
139
+ my $prefixes = [ @$prefixesRef ];
140
+
141
+ # Sort prefixes to be longest to shortest.
142
+ @$prefixes = sort { length $b <=> length $a } @$prefixes;
143
+
144
+ $self->[IGNORED_PREFIXES]->{$type} = $prefixes;
145
+ };
146
+ };
147
+
148
+
149
+ #
150
+ # Function: HasIgnoredPrefixes
151
+ #
152
+ # Returns whether the language has any ignored prefixes at all.
153
+ #
154
+ sub HasIgnoredPrefixes
155
+ { return defined $_[0]->[IGNORED_PREFIXES]; };
156
+
157
+
158
+ #
159
+ # Function: CopyIgnoredPrefixesOf
160
+ #
161
+ # Copies all the ignored prefix settings of the passed <NaturalDocs::Languages::Base> object.
162
+ #
163
+ sub CopyIgnoredPrefixesOf #(language)
164
+ {
165
+ my ($self, $language) = @_;
166
+
167
+ if ($language->HasIgnoredPrefixes())
168
+ {
169
+ $self->[IGNORED_PREFIXES] = { };
170
+
171
+ while (my ($topicType, $prefixes) = each %{$language->[IGNORED_PREFIXES]})
172
+ {
173
+ $self->[IGNORED_PREFIXES]->{$topicType} = [ @$prefixes ];
174
+ };
175
+ };
176
+ };
177
+
178
+
179
+
180
+ ###############################################################################
181
+ # Group: Parsing Functions
182
+
183
+
184
+ #
185
+ # Function: ParseFile
186
+ #
187
+ # Parses the passed source file, sending comments acceptable for documentation to <NaturalDocs::Parser->OnComment()>.
188
+ # This *must* be defined by a subclass.
189
+ #
190
+ # Parameters:
191
+ #
192
+ # sourceFile - The <FileName> of the source file to parse.
193
+ # topicList - A reference to the list of <NaturalDocs::Parser::ParsedTopics> being built by the file.
194
+ #
195
+ # Returns:
196
+ #
197
+ # The array ( autoTopics, scopeRecord ).
198
+ #
199
+ # autoTopics - An arrayref of automatically generated <NaturalDocs::Parser::ParsedTopics> from the file, or undef if none.
200
+ # scopeRecord - An arrayref of <NaturalDocs::Languages::Advanced::ScopeChanges>, or undef if none.
201
+ #
202
+
203
+
204
+ #
205
+ # Function: ParsePrototype
206
+ #
207
+ # Parses the prototype and returns it as a <NaturalDocs::Languages::Prototype> object.
208
+ #
209
+ # Parameters:
210
+ #
211
+ # type - The <TopicType>.
212
+ # prototype - The text prototype.
213
+ #
214
+ # Returns:
215
+ #
216
+ # A <NaturalDocs::Languages::Prototype> object.
217
+ #
218
+ sub ParsePrototype #(type, prototype)
219
+ {
220
+ my ($self, $type, $prototype) = @_;
221
+
222
+ my $isClass = NaturalDocs::Topics->TypeInfo($type)->ClassHierarchy();
223
+
224
+ if ($prototype !~ /\(.*[^ ].*\)/ && (!$isClass || $prototype !~ /\{.*[^ ].*\}/))
225
+ {
226
+ my $object = NaturalDocs::Languages::Prototype->New($prototype);
227
+ return $object;
228
+ };
229
+
230
+
231
+ # Parse the parameters out of the prototype.
232
+
233
+ my @tokens = $prototype =~ /([^\(\)\[\]\{\}\<\>\'\"\,\;]+|.)/g;
234
+
235
+ my $parameter;
236
+ my @parameterLines;
237
+
238
+ my @symbolStack;
239
+ my $finishedParameters;
240
+
241
+ my ($beforeParameters, $afterParameters);
242
+
243
+ foreach my $token (@tokens)
244
+ {
245
+ if ($finishedParameters)
246
+ { $afterParameters .= $token; }
247
+
248
+ elsif ($symbolStack[-1] eq '\'' || $symbolStack[-1] eq '"')
249
+ {
250
+ if ($symbolStack[0] eq '(' || ($isClass && $symbolStack[0] eq '{'))
251
+ { $parameter .= $token; }
252
+ else
253
+ { $beforeParameters .= $token; };
254
+
255
+ if ($token eq $symbolStack[-1])
256
+ { pop @symbolStack; };
257
+ }
258
+
259
+ elsif ($token =~ /^[\(\[\{\<\'\"]$/)
260
+ {
261
+ if ($symbolStack[0] eq '(' || ($isClass && $symbolStack[0] eq '{'))
262
+ { $parameter .= $token; }
263
+ else
264
+ { $beforeParameters .= $token; };
265
+
266
+ push @symbolStack, $token;
267
+ }
268
+
269
+ elsif ( ($token eq ')' && $symbolStack[-1] eq '(') ||
270
+ ($token eq ']' && $symbolStack[-1] eq '[') ||
271
+ ($token eq '}' && $symbolStack[-1] eq '{') ||
272
+ ($token eq '>' && $symbolStack[-1] eq '<') )
273
+ {
274
+ if ($symbolStack[0] eq '(')
275
+ {
276
+ if ($token eq ')' && scalar @symbolStack == 1)
277
+ {
278
+ if ($parameter ne ' ')
279
+ { push @parameterLines, $parameter; };
280
+
281
+ $finishedParameters = 1;
282
+ $afterParameters .= $token;
283
+ }
284
+ else
285
+ { $parameter .= $token; };
286
+ }
287
+ elsif ($isClass && $symbolStack[0] eq '{')
288
+ {
289
+ if ($token eq '}' && scalar @symbolStack == 1)
290
+ {
291
+ if ($parameter ne ' ')
292
+ { push @parameterLines, $parameter; };
293
+
294
+ $finishedParameters = 1;
295
+ $afterParameters .= $token;
296
+ }
297
+ else
298
+ { $parameter .= $token; };
299
+ }
300
+ else
301
+ {
302
+ $beforeParameters .= $token;
303
+ };
304
+
305
+ pop @symbolStack;
306
+ }
307
+
308
+ elsif ($token eq ',' || $token eq ';')
309
+ {
310
+ if ($symbolStack[0] eq '(' || ($isClass && $symbolStack[0] eq '{'))
311
+ {
312
+ if (scalar @symbolStack == 1)
313
+ {
314
+ push @parameterLines, $parameter . $token;
315
+ $parameter = undef;
316
+ }
317
+ else
318
+ {
319
+ $parameter .= $token;
320
+ };
321
+ }
322
+ else
323
+ {
324
+ $beforeParameters .= $token;
325
+ };
326
+ }
327
+
328
+ else
329
+ {
330
+ if ($symbolStack[0] eq '(' || ($isClass && $symbolStack[0] eq '{'))
331
+ { $parameter .= $token; }
332
+ else
333
+ { $beforeParameters .= $token; };
334
+ };
335
+ };
336
+
337
+ foreach my $part (\$beforeParameters, \$afterParameters)
338
+ {
339
+ $$part =~ s/^ //;
340
+ $$part =~ s/ $//;
341
+ };
342
+
343
+ my $prototypeObject = NaturalDocs::Languages::Prototype->New($beforeParameters, $afterParameters);
344
+
345
+
346
+ # Parse the actual parameters.
347
+
348
+ foreach my $parameterLine (@parameterLines)
349
+ {
350
+ $prototypeObject->AddParameter( $self->ParseParameterLine($parameterLine) );
351
+ };
352
+
353
+ return $prototypeObject;
354
+ };
355
+
356
+
357
+ #
358
+ # Function: ParseParameterLine
359
+ #
360
+ # Parses a prototype parameter line and returns it as a <NaturalDocs::Languages::Prototype::Parameter> object.
361
+ #
362
+ # This vesion assumes a C++ style line. If you need a Pascal style line, override this function to forward to
363
+ # <ParsePascalParameterLine()>.
364
+ #
365
+ # > Function(parameter, type parameter, type parameter = value);
366
+ #
367
+ sub ParseParameterLine #(line)
368
+ {
369
+ my ($self, $line) = @_;
370
+
371
+ $line =~ s/^ //;
372
+ $line =~ s/ $//;
373
+
374
+ my @tokens = $line =~ /([^ \(\)\{\}\[\]\<\>\'\"\=]+|.)/g;
375
+
376
+ my @symbolStack;
377
+ my @parameterWords = ( undef );
378
+ my ($defaultValue, $defaultValuePrefix, $inDefaultValue);
379
+
380
+ foreach my $token (@tokens)
381
+ {
382
+ if ($inDefaultValue)
383
+ { $defaultValue .= $token; }
384
+
385
+ elsif ($symbolStack[-1] eq '\'' || $symbolStack[-1] eq '"')
386
+ {
387
+ $parameterWords[-1] .= $token;
388
+
389
+ if ($token eq $symbolStack[-1])
390
+ { pop @symbolStack; };
391
+ }
392
+
393
+ elsif ($token =~ /^[\(\[\{\<\'\"]$/)
394
+ {
395
+ push @symbolStack, $token;
396
+ $parameterWords[-1] .= $token;
397
+ }
398
+
399
+ elsif ( ($token eq ')' && $symbolStack[-1] eq '(') ||
400
+ ($token eq ']' && $symbolStack[-1] eq '[') ||
401
+ ($token eq '}' && $symbolStack[-1] eq '{') ||
402
+ ($token eq '>' && $symbolStack[-1] eq '<') )
403
+ {
404
+ pop @symbolStack;
405
+ $parameterWords[-1] .= $token;
406
+ }
407
+
408
+ elsif ($token eq ' ')
409
+ {
410
+ if (!scalar @symbolStack)
411
+ { push @parameterWords, undef; }
412
+ else
413
+ { $parameterWords[-1] .= $token; };
414
+ }
415
+
416
+ elsif ($token eq '=')
417
+ {
418
+ if (!scalar @symbolStack)
419
+ {
420
+ $defaultValuePrefix = $token;
421
+ $inDefaultValue = 1;
422
+ }
423
+ else
424
+ { $parameterWords[-1] .= $token; };
425
+ }
426
+
427
+ else
428
+ {
429
+ $parameterWords[-1] .= $token;
430
+ };
431
+ };
432
+
433
+ my ($name, $namePrefix, $type, $typePrefix);
434
+
435
+ if (!$parameterWords[-1])
436
+ { pop @parameterWords; };
437
+
438
+ $name = pop @parameterWords;
439
+
440
+ if ($parameterWords[-1]=~ /([\*\&]+)$/)
441
+ {
442
+ $namePrefix = $1;
443
+ $parameterWords[-1] = substr($parameterWords[-1], 0, 0 - length($namePrefix));
444
+ $parameterWords[-1] =~ s/ $//;
445
+
446
+ if (!$parameterWords[-1])
447
+ { pop @parameterWords; };
448
+ }
449
+ elsif ($name =~ /^([\*\&]+)/)
450
+ {
451
+ $namePrefix = $1;
452
+ $name = substr($name, length($namePrefix));
453
+ $name =~ s/^ //;
454
+ };
455
+
456
+ $type = pop @parameterWords;
457
+ $typePrefix = join(' ', @parameterWords);
458
+
459
+ if ($typePrefix)
460
+ { $typePrefix .= ' '; };
461
+
462
+ if ($type =~ /^([a-z0-9_\:\.]+(?:\.|\:\:))[a-z0-9_]/i)
463
+ {
464
+ my $attachedTypePrefix = $1;
465
+
466
+ $typePrefix .= $attachedTypePrefix;
467
+ $type = substr($type, length($attachedTypePrefix));
468
+ };
469
+
470
+ $defaultValue =~ s/ $//;
471
+
472
+ return NaturalDocs::Languages::Prototype::Parameter->New($type, $typePrefix, $name, $namePrefix,
473
+ $defaultValue, $defaultValuePrefix);
474
+ };
475
+
476
+
477
+ #
478
+ # Function: ParsePascalParameterLine
479
+ #
480
+ # Parses a Pascal-like prototype parameter line and returns it as a <NaturalDocs::Languages::Prototype::Parameter> object.
481
+ # Pascal lines are as follows:
482
+ #
483
+ # > Function (name: type; name, name: type := value)
484
+ #
485
+ # Also supports ActionScript lines
486
+ #
487
+ # > Function (name: type, name, name: type = value)
488
+ #
489
+ sub ParsePascalParameterLine #(line)
490
+ {
491
+ my ($self, $line) = @_;
492
+
493
+ $line =~ s/^ //;
494
+ $line =~ s/ $//;
495
+
496
+ my @tokens = $line =~ /([^\(\)\{\}\[\]\<\>\'\"\=\:]+|\:\=|.)/g;
497
+ my ($type, $name, $defaultValue, $defaultValuePrefix, $afterName, $afterDefaultValue);
498
+ my @symbolStack;
499
+
500
+ foreach my $token (@tokens)
501
+ {
502
+ if ($afterDefaultValue)
503
+ { $defaultValue .= $token; }
504
+
505
+ elsif ($symbolStack[-1] eq '\'' || $symbolStack[-1] eq '"')
506
+ {
507
+ if ($afterName)
508
+ { $type .= $token; }
509
+ else
510
+ { $name .= $token; };
511
+
512
+ if ($token eq $symbolStack[-1])
513
+ { pop @symbolStack; };
514
+ }
515
+
516
+ elsif ($token =~ /^[\(\[\{\<\'\"]$/)
517
+ {
518
+ push @symbolStack, $token;
519
+
520
+ if ($afterName)
521
+ { $type .= $token; }
522
+ else
523
+ { $name .= $token; };
524
+ }
525
+
526
+ elsif ( ($token eq ')' && $symbolStack[-1] eq '(') ||
527
+ ($token eq ']' && $symbolStack[-1] eq '[') ||
528
+ ($token eq '}' && $symbolStack[-1] eq '{') ||
529
+ ($token eq '>' && $symbolStack[-1] eq '<') )
530
+ {
531
+ pop @symbolStack;
532
+
533
+ if ($afterName)
534
+ { $type .= $token; }
535
+ else
536
+ { $name .= $token; };
537
+ }
538
+
539
+ elsif ($afterName)
540
+ {
541
+ if (($token eq ':=' || $token eq '=') && !scalar @symbolStack)
542
+ {
543
+ $defaultValuePrefix = $token;
544
+ $afterDefaultValue = 1;
545
+ }
546
+ else
547
+ { $type .= $token; };
548
+ }
549
+
550
+ elsif ($token eq ':' && !scalar @symbolStack)
551
+ {
552
+ $name .= $token;
553
+ $afterName = 1;
554
+ }
555
+
556
+ else
557
+ { $name .= $token; };
558
+ };
559
+
560
+ foreach my $part (\$type, \$name, \$defaultValue)
561
+ {
562
+ $$part =~ s/^ //;
563
+ $$part =~ s/ $//;
564
+ };
565
+
566
+ return NaturalDocs::Languages::Prototype::Parameter->New($type, undef, $name, undef, $defaultValue, $defaultValuePrefix);
567
+ };
568
+
569
+
570
+ #
571
+ # Function: TypeBeforeParameter
572
+ #
573
+ # Returns whether the type appears before the parameter in prototypes.
574
+ #
575
+ # For example, it does in C++
576
+ # > void Function (int a, int b)
577
+ #
578
+ # but does not in Pascal
579
+ # > function Function (a: int; b, c: int)
580
+ #
581
+ sub TypeBeforeParameter
582
+ {
583
+ return 1;
584
+ };
585
+
586
+
587
+
588
+ #
589
+ # Function: IgnoredPrefixLength
590
+ #
591
+ # Returns the length of the prefix that should be ignored in the index, or zero if none.
592
+ #
593
+ # Parameters:
594
+ #
595
+ # name - The name of the symbol.
596
+ # type - The symbol's <TopicType>.
597
+ #
598
+ # Returns:
599
+ #
600
+ # The length of the prefix to ignore, or zero if none.
601
+ #
602
+ sub IgnoredPrefixLength #(name, type)
603
+ {
604
+ my ($self, $name, $type) = @_;
605
+
606
+ foreach my $prefixes ($self->IgnoredPrefixesFor($type), $self->IgnoredPrefixesFor(::TOPIC_GENERAL()))
607
+ {
608
+ if (defined $prefixes)
609
+ {
610
+ foreach my $prefix (@$prefixes)
611
+ {
612
+ if (substr($name, 0, length($prefix)) eq $prefix)
613
+ { return length($prefix); };
614
+ };
615
+ };
616
+ };
617
+
618
+ return 0;
619
+ };
620
+
621
+
622
+
623
+ ###############################################################################
624
+ # Group: Support Functions
625
+
626
+
627
+ #
628
+ # Function: StripOpeningSymbols
629
+ #
630
+ # Determines if the line starts with any of the passed symbols, and if so, replaces it with spaces. This only happens
631
+ # if the only thing before it on the line is whitespace.
632
+ #
633
+ # Parameters:
634
+ #
635
+ # lineRef - A reference to the line to check.
636
+ # symbols - An arrayref of the symbols to check for.
637
+ #
638
+ # Returns:
639
+ #
640
+ # If the line starts with any of the passed comment symbols, it will replace it in the line with spaces and return the symbol.
641
+ # If the line doesn't, it will leave the line alone and return undef.
642
+ #
643
+ sub StripOpeningSymbols #(lineRef, symbols)
644
+ {
645
+ my ($self, $lineRef, $symbols) = @_;
646
+
647
+ if (!defined $symbols)
648
+ { return undef; };
649
+
650
+ my ($index, $symbol) = ::FindFirstSymbol($$lineRef, $symbols);
651
+
652
+ if ($index != -1 && substr($$lineRef, 0, $index) =~ /^[ \t]*$/)
653
+ {
654
+ return substr($$lineRef, $index, length($symbol), ' ' x length($symbol));
655
+ };
656
+
657
+ return undef;
658
+ };
659
+
660
+
661
+ #
662
+ # Function: StripOpeningJavaDocSymbols
663
+ #
664
+ # Determines if the line starts with any of the passed symbols, and if so, replaces it with spaces. This only happens
665
+ # if the only thing before it on the line is whitespace and the next character after it is whitespace or the end of the line.
666
+ #
667
+ # Parameters:
668
+ #
669
+ # lineRef - A reference to the line to check.
670
+ # symbols - An arrayref of the symbols to check for.
671
+ #
672
+ # Returns:
673
+ #
674
+ # If the line starts with any of the passed comment symbols, it will replace it in the line with spaces and return the symbol.
675
+ # If the line doesn't, it will leave the line alone and return undef.
676
+ #
677
+ sub StripOpeningJavaDocSymbols #(lineRef, symbols)
678
+ {
679
+ my ($self, $lineRef, $symbols) = @_;
680
+
681
+ if (!defined $symbols)
682
+ { return undef; };
683
+
684
+ my ($index, $symbol) = ::FindFirstSymbol($$lineRef, $symbols);
685
+
686
+ if ($index != -1 && substr($$lineRef, 0, $index) =~ /^[ \t]*$/ && substr($$lineRef, $index + length($symbol), 1) =~ /^[ \t]?$/)
687
+ {
688
+ return substr($$lineRef, $index, length($symbol), ' ' x length($symbol));
689
+ };
690
+
691
+ return undef;
692
+ };
693
+
694
+
695
+ #
696
+ # Function: StripOpeningBlockSymbols
697
+ #
698
+ # Determines if the line starts with any of the opening symbols in the passed symbol pairs, and if so, replaces it with spaces.
699
+ # This only happens if the only thing before it on the line is whitespace.
700
+ #
701
+ # Parameters:
702
+ #
703
+ # lineRef - A reference to the line to check.
704
+ # symbolPairs - An arrayref of the symbol pairs to check for. Pairs are specified as two consecutive array entries, with the
705
+ # opening symbol first.
706
+ #
707
+ # Returns:
708
+ #
709
+ # If the line starts with any of the opening symbols, it will replace it in the line with spaces and return the closing symbol.
710
+ # If the line doesn't, it will leave the line alone and return undef.
711
+ #
712
+ sub StripOpeningBlockSymbols #(lineRef, symbolPairs)
713
+ {
714
+ my ($self, $lineRef, $symbolPairs) = @_;
715
+
716
+ if (!defined $symbolPairs)
717
+ { return undef; };
718
+
719
+ for (my $i = 0; $i < scalar @$symbolPairs; $i += 2)
720
+ {
721
+ my $index = index($$lineRef, $symbolPairs->[$i]);
722
+
723
+ if ($index != -1 && substr($$lineRef, 0, $index) =~ /^[ \t]*$/)
724
+ {
725
+ substr($$lineRef, $index, length($symbolPairs->[$i]), ' ' x length($symbolPairs->[$i]));
726
+ return $symbolPairs->[$i + 1];
727
+ };
728
+ };
729
+
730
+ return undef;
731
+ };
732
+
733
+
734
+ #
735
+ # Function: StripOpeningJavaDocBlockSymbols
736
+ #
737
+ # Determines if the line starts with any of the opening symbols in the passed symbol pairs, and if so, replaces it with spaces.
738
+ # This only happens if the only thing before it on the line is whitespace and the next character is whitespace or the end of the line.
739
+ #
740
+ # Parameters:
741
+ #
742
+ # lineRef - A reference to the line to check.
743
+ # symbolPairs - An arrayref of the symbol pairs to check for. Pairs are specified as two consecutive array entries, with the
744
+ # opening symbol first.
745
+ #
746
+ # Returns:
747
+ #
748
+ # If the line starts with any of the opening symbols, it will replace it in the line with spaces and return the closing symbol.
749
+ # If the line doesn't, it will leave the line alone and return undef.
750
+ #
751
+ sub StripOpeningJavaDocBlockSymbols #(lineRef, symbolPairs)
752
+ {
753
+ my ($self, $lineRef, $symbolPairs) = @_;
754
+
755
+ if (!defined $symbolPairs)
756
+ { return undef; };
757
+
758
+ for (my $i = 0; $i < scalar @$symbolPairs; $i += 2)
759
+ {
760
+ my $index = index($$lineRef, $symbolPairs->[$i]);
761
+
762
+ if ($index != -1 && substr($$lineRef, 0, $index) =~ /^[ \t]*$/ &&
763
+ substr($$lineRef, $index + length($symbolPairs->[$i]), 1) =~ /^[ \t]?$/)
764
+ {
765
+ substr($$lineRef, $index, length($symbolPairs->[$i]), ' ' x length($symbolPairs->[$i]));
766
+ return $symbolPairs->[$i + 1];
767
+ };
768
+ };
769
+
770
+ return undef;
771
+ };
772
+
773
+
774
+ #
775
+ # Function: StripClosingSymbol
776
+ #
777
+ # Determines if the line contains a symbol, and if so, truncates it just before the symbol.
778
+ #
779
+ # Parameters:
780
+ #
781
+ # lineRef - A reference to the line to check.
782
+ # symbol - The symbol to check for.
783
+ #
784
+ # Returns:
785
+ #
786
+ # The remainder of the line, or undef if the symbol was not found.
787
+ #
788
+ sub StripClosingSymbol #(lineRef, symbol)
789
+ {
790
+ my ($self, $lineRef, $symbol) = @_;
791
+
792
+ my $index = index($$lineRef, $symbol);
793
+
794
+ if ($index != -1)
795
+ {
796
+ my $lineRemainder = substr($$lineRef, $index + length($symbol));
797
+ $$lineRef = substr($$lineRef, 0, $index);
798
+
799
+ return $lineRemainder;
800
+ }
801
+ else
802
+ { return undef; };
803
+ };
804
+
805
+
806
+ #
807
+ # Function: NormalizePrototype
808
+ #
809
+ # Normalizes a prototype. Specifically, condenses spaces, tabs, and line breaks into single spaces and removes leading and
810
+ # trailing ones.
811
+ #
812
+ # Parameters:
813
+ #
814
+ # prototype - The original prototype string.
815
+ #
816
+ # Returns:
817
+ #
818
+ # The normalized prototype.
819
+ #
820
+ sub NormalizePrototype #(prototype)
821
+ {
822
+ my ($self, $prototype) = @_;
823
+
824
+ $prototype =~ tr/ \t\r\n/ /s;
825
+ $prototype =~ s/^ //;
826
+ $prototype =~ s/ $//;
827
+
828
+ return $prototype;
829
+ };
830
+
831
+
832
+ 1;