bixbite 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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,186 @@
1
+ ###############################################################################
2
+ #
3
+ # Package: NaturalDocs::SymbolTable::File
4
+ #
5
+ ###############################################################################
6
+ #
7
+ # A class representing a file, keeping track of what symbols and references are defined in it.
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::SymbolTable::File;
18
+
19
+
20
+ ###############################################################################
21
+ # Group: Implementation
22
+
23
+ #
24
+ # Constants: Members
25
+ #
26
+ # The class is implemented as a blessed arrayref. The following constants are its members.
27
+ #
28
+ # SYMBOLS - An existence hashref of the <SymbolStrings> it defines.
29
+ # REFERENCES - An existence hashref of the <ReferenceStrings> in the file.
30
+ #
31
+
32
+ # DEPENDENCY: New() depends on the order of these constants. If they change, New() has to be updated.
33
+ use constant SYMBOLS => 0;
34
+ use constant REFERENCES => 1;
35
+
36
+
37
+ ###############################################################################
38
+ # Group: Modification Functions
39
+
40
+
41
+ #
42
+ # Function: New
43
+ #
44
+ # Creates and returns a new object.
45
+ #
46
+ sub New
47
+ {
48
+ my $package = shift;
49
+
50
+ # Let's make it safe, since normally you can pass values to New. Having them just be ignored would be an obscure error.
51
+ if (scalar @_)
52
+ { die "You can't pass values to NaturalDocs::SymbolTable::File->New()\n"; };
53
+
54
+ # DEPENDENCY: This code depends on the order of the member constants.
55
+ my $object = [ { }, { } ];
56
+ bless $object, $package;
57
+
58
+ return $object;
59
+ };
60
+
61
+
62
+ #
63
+ # Function: AddSymbol
64
+ #
65
+ # Adds a <SymbolString> definition.
66
+ #
67
+ # Parameters:
68
+ #
69
+ # symbol - The <SymbolString> being added.
70
+ #
71
+ sub AddSymbol #(symbol)
72
+ {
73
+ my ($self, $symbol) = @_;
74
+ $self->[SYMBOLS]{$symbol} = 1;
75
+ };
76
+
77
+
78
+ #
79
+ # Function: DeleteSymbol
80
+ #
81
+ # Removes a <SymbolString> definition.
82
+ #
83
+ # Parameters:
84
+ #
85
+ # symbol - The <SymbolString> to delete.
86
+ #
87
+ sub DeleteSymbol #(symbol)
88
+ {
89
+ my ($self, $symbol) = @_;
90
+ delete $self->[SYMBOLS]{$symbol};
91
+ };
92
+
93
+
94
+ #
95
+ # Function: AddReference
96
+ #
97
+ # Adds a reference definition.
98
+ #
99
+ # Parameters:
100
+ #
101
+ # referenceString - The <ReferenceString> being added.
102
+ #
103
+ sub AddReference #(referenceString)
104
+ {
105
+ my ($self, $referenceString) = @_;
106
+ $self->[REFERENCES]{$referenceString} = 1;
107
+ };
108
+
109
+
110
+ #
111
+ # Function: DeleteReference
112
+ #
113
+ # Removes a reference definition.
114
+ #
115
+ # Parameters:
116
+ #
117
+ # referenceString - The <ReferenceString> to delete.
118
+ #
119
+ sub DeleteReference #(referenceString)
120
+ {
121
+ my ($self, $referenceString) = @_;
122
+ delete $self->[REFERENCES]{$referenceString};
123
+ };
124
+
125
+
126
+
127
+ ###############################################################################
128
+ # Group: Information Functions
129
+
130
+
131
+ #
132
+ # Function: HasAnything
133
+ #
134
+ # Returns whether the file has any symbol or reference definitions at all.
135
+ #
136
+ sub HasAnything
137
+ {
138
+ return (scalar keys %{$_[0]->[SYMBOLS]} || scalar keys %{$_[0]->[REFERENCES]});
139
+ };
140
+
141
+ #
142
+ # Function: Symbols
143
+ #
144
+ # Returns an array of all the <SymbolStrings> defined in this file. If none, returns an empty array.
145
+ #
146
+ sub Symbols
147
+ {
148
+ return keys %{$_[0]->[SYMBOLS]};
149
+ };
150
+
151
+
152
+ #
153
+ # Function: References
154
+ #
155
+ # Returns an array of all the <ReferenceStrings> defined in this file. If none, returns an empty array.
156
+ #
157
+ sub References
158
+ {
159
+ return keys %{$_[0]->[REFERENCES]};
160
+ };
161
+
162
+
163
+ #
164
+ # Function: DefinesSymbol
165
+ #
166
+ # Returns whether the file defines the passed <SymbolString> or not.
167
+ #
168
+ sub DefinesSymbol #(symbol)
169
+ {
170
+ my ($self, $symbol) = @_;
171
+ return exists $self->[SYMBOLS]{$symbol};
172
+ };
173
+
174
+
175
+ #
176
+ # Function: DefinesReference
177
+ #
178
+ # Returns whether the file defines the passed <ReferenceString> or not.
179
+ #
180
+ sub DefinesReference #(referenceString)
181
+ {
182
+ my ($self, $referenceString) = @_;
183
+ return exists $self->[REFERENCES]{$referenceString};
184
+ };
185
+
186
+ 1;
@@ -0,0 +1,522 @@
1
+ ###############################################################################
2
+ #
3
+ # Class: NaturalDocs::SymbolTable::IndexElement
4
+ #
5
+ ###############################################################################
6
+ #
7
+ # A class representing part of an indexed symbol.
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 Tie::RefHash;
15
+
16
+ use strict;
17
+ use integer;
18
+
19
+
20
+ package NaturalDocs::SymbolTable::IndexElement;
21
+
22
+
23
+ #
24
+ # Topic: How IndexElements Work
25
+ #
26
+ # This is a little tricky, so make sure you understand this. Indexes are sorted by symbol, then packages, then file. If there is only
27
+ # one package for a symbol, or one file definition for a package/symbol, they are added inline to the entry. However, if there are
28
+ # multiple packages or files, the function for it returns an arrayref of IndexElements instead. Which members are defined and
29
+ # undefined should follow common sense. For example, if a symbol is defined in multiple packages, the symbol's IndexElement
30
+ # will not define <File()>, <Type()>, or <Prototype()>; those will be defined in child elements. Similarly, the child elements will
31
+ # not define <Symbol()> since it's redundant.
32
+ #
33
+ # Diagrams may be clearer. If a member isn't listed for an element, it isn't defined.
34
+ #
35
+ # A symbol that only has one package and file:
36
+ # > [Element]
37
+ # > - Symbol
38
+ # > - Package
39
+ # > - File
40
+ # > - Type
41
+ # > - Prototype
42
+ # > - Summary
43
+ #
44
+ # A symbol that is defined by multiple packages, each with only one file:
45
+ # > [Element]
46
+ # > - Symbol
47
+ # > - Package
48
+ # > [Element]
49
+ # > - Package
50
+ # > - File
51
+ # > - Type
52
+ # > - Prototype
53
+ # > - Summary
54
+ # > [Element]
55
+ # > - ...
56
+ #
57
+ # A symbol that is defined by one package, but has multiple files
58
+ # > [Element]
59
+ # > - Symbol
60
+ # > - Package
61
+ # > - File
62
+ # > [Element]
63
+ # > - File
64
+ # > - Type
65
+ # > - Protype
66
+ # > - Summary
67
+ # > [Element]
68
+ # > - ...
69
+ #
70
+ # A symbol that is defined by multiple packages which have multiple files:
71
+ # > [Element]
72
+ # > - Symbol
73
+ # > - Package
74
+ # > [Element]
75
+ # > - Package
76
+ # > - File
77
+ # > [Element]
78
+ # > - File
79
+ # > - Type
80
+ # > - Prototype
81
+ # > - Summary
82
+ # > [Element]
83
+ # > - ...
84
+ # > [Element]
85
+ # > - ...
86
+ #
87
+ # Why is it done this way?:
88
+ #
89
+ # Because it makes it easier to generate nice indexes since all the splitting and combining is done for you. If a symbol
90
+ # has only one package, you just want to link to it, you don't want to break out a subindex for just one package. However, if
91
+ # it has multiple package, you do want the subindex and to link to each one individually. Use <HasMultiplePackages()> and
92
+ # <HasMultipleFiles()> to determine whether you need to add a subindex for it.
93
+ #
94
+ #
95
+ # Combining Properties:
96
+ #
97
+ # All IndexElements also have combining properties set.
98
+ #
99
+ # CombinedType - The general <TopicType> of the entry. Conflicts combine into <TOPIC_GENERAL>.
100
+ # PackageSeparator - The package separator symbol of the entry. Conflicts combine into a dot.
101
+ #
102
+ # So if an IndexElement only has one definition, <CombinedType()> is the same as the <TopicType> and <PackageSeparator()>
103
+ # is that of the definition's language. If other definitions are added and they have the same properties, the combined properties
104
+ # will remain the same. However, if they're different, they switch values as noted above.
105
+ #
106
+ #
107
+ # Sortable Symbol:
108
+ #
109
+ # <SortableSymbol()> is a pseudo-combining property. There were a few options for dealing with multiple languages defining
110
+ # the same symbol but stripping different prefixes off it, but ultimately I decided to go with whatever the language does that
111
+ # has the most definitions. There's not likely to be many conflicts here in the real world; probably the only thing would be
112
+ # defining it in a text file and forgetting to specify the prefixes to strip there too. So this works.
113
+ #
114
+ # Ties are broken pretty much randomly, except that text files always lose if its one of the options.
115
+ #
116
+ # It's a pseudo-combining property because it's done after the IndexElements are all filled in and only stored in the top-level
117
+ # ones.
118
+ #
119
+
120
+
121
+ ###############################################################################
122
+ # Group: Implementation
123
+
124
+ #
125
+ # Constants: Members
126
+ #
127
+ # The class is implemented as a blessed arrayref. The following constants are its members.
128
+ #
129
+ # SYMBOL - The <SymbolString> without the package portion.
130
+ # PACKAGE - The package <SymbolString>. Will be a package <SymbolString>, undef for global, or an arrayref of
131
+ # <NaturalDocs::SymbolTable::IndexElement> objects if multiple packages define the symbol.
132
+ # FILE - The <FileName> the package/symbol is defined in. Will be the file name or an arrayref of
133
+ # <NaturalDocs::SymbolTable::IndexElements> if multiple files define the package/symbol.
134
+ # TYPE - The package/symbol/file <TopicType>.
135
+ # PROTOTYPE - The package/symbol/file prototype, or undef if not applicable.
136
+ # SUMMARY - The package/symbol/file summary, or undef if not applicable.
137
+ # COMBINED_TYPE - The combined <TopicType> of the element.
138
+ # PACKAGE_SEPARATOR - The combined package separator symbol of the element.
139
+ # SORTABLE_SYMBOL - The sortable symbol as a text string.
140
+ # IGNORED_PREFIX - The part of the symbol that was stripped off to make the sortable symbol.
141
+ #
142
+ use NaturalDocs::DefineMembers 'SYMBOL', 'Symbol()',
143
+ 'PACKAGE', 'Package()',
144
+ 'FILE', 'File()',
145
+ 'TYPE', 'Type()',
146
+ 'PROTOTYPE', 'Prototype()',
147
+ 'SUMMARY', 'Summary()',
148
+ 'COMBINED_TYPE', 'CombinedType()',
149
+ 'PACKAGE_SEPARATOR', 'PackageSeparator()',
150
+ 'SORTABLE_SYMBOL', 'SortableSymbol()',
151
+ 'IGNORED_PREFIX', 'IgnoredPrefix()';
152
+ # DEPENDENCY: New() depends on the order of these constants and that there is no inheritance..
153
+
154
+
155
+ ###############################################################################
156
+ # Group: Modification Functions
157
+
158
+ #
159
+ # Function: New
160
+ #
161
+ # Returns a new object.
162
+ #
163
+ # This should only be used for creating an entirely new symbol. You should *not* pass arrayrefs as package or file parameters
164
+ # if you are calling this externally. Use <Merge()> instead.
165
+ #
166
+ # Parameters:
167
+ #
168
+ # symbol - The <SymbolString> without the package portion.
169
+ # package - The package <SymbolString>, or undef for global.
170
+ # file - The symbol's definition file.
171
+ # type - The symbol's <TopicType>.
172
+ # prototype - The symbol's prototype, if applicable.
173
+ # summary - The symbol's summary, if applicable.
174
+ #
175
+ # Optional Parameters:
176
+ #
177
+ # These parameters don't need to be specified. You should ignore them when calling this externally.
178
+ #
179
+ # combinedType - The symbol's combined <TopicType>.
180
+ # packageSeparator - The symbol's combined package separator symbol.
181
+ #
182
+ sub New #(symbol, package, file, type, prototype, summary, combinedType, packageSeparator)
183
+ {
184
+ # DEPENDENCY: This depends on the parameter list being in the same order as the constants.
185
+
186
+ my $self = shift;
187
+
188
+ my $object = [ @_ ];
189
+ bless $object, $self;
190
+
191
+ if (!defined $object->[COMBINED_TYPE])
192
+ { $object->[COMBINED_TYPE] = $object->[TYPE]; };
193
+
194
+ if (!defined $object->[PACKAGE_SEPARATOR])
195
+ {
196
+ if ($object->[TYPE] eq ::TOPIC_FILE())
197
+ { $object->[PACKAGE_SEPARATOR] = '.'; }
198
+ else
199
+ {
200
+ $object->[PACKAGE_SEPARATOR] = NaturalDocs::Languages->LanguageOf($object->[FILE])->PackageSeparator();
201
+ };
202
+ };
203
+
204
+ return $object;
205
+ };
206
+
207
+
208
+ #
209
+ # Function: Merge
210
+ #
211
+ # Adds another definition of the same symbol. Perhaps it has a different package or defining file.
212
+ #
213
+ # Parameters:
214
+ #
215
+ # package - The package <SymbolString>, or undef for global.
216
+ # file - The symbol's definition file.
217
+ # type - The symbol's <TopicType>.
218
+ # prototype - The symbol's protoype if applicable.
219
+ # summary - The symbol's summary if applicable.
220
+ #
221
+ sub Merge #(package, file, type, prototype, summary)
222
+ {
223
+ my ($self, $package, $file, $type, $prototype, $summary) = @_;
224
+
225
+ # If there's only one package...
226
+ if (!$self->HasMultiplePackages())
227
+ {
228
+ # If there's one package and it's the same as the new one...
229
+ if ($package eq $self->Package())
230
+ {
231
+ $self->MergeFile($file, $type, $prototype, $summary);
232
+ }
233
+
234
+ # If there's one package and the new one is different...
235
+ else
236
+ {
237
+ my $selfDefinition = NaturalDocs::SymbolTable::IndexElement->New(undef, $self->Package(), $self->File(),
238
+ $self->Type(), $self->Prototype(),
239
+ $self->Summary(), $self->CombinedType(),
240
+ $self->PackageSeparator());
241
+ my $newDefinition = NaturalDocs::SymbolTable::IndexElement->New(undef, $package, $file, $type, $prototype,
242
+ $summary);
243
+
244
+ $self->[PACKAGE] = [ $selfDefinition, $newDefinition ];
245
+ $self->[FILE] = undef;
246
+ $self->[TYPE] = undef;
247
+ $self->[PROTOTYPE] = undef;
248
+ $self->[SUMMARY] = undef;
249
+
250
+ if ($newDefinition->Type() ne $self->CombinedType())
251
+ { $self->[COMBINED_TYPE] = ::TOPIC_GENERAL(); };
252
+ if ($newDefinition->PackageSeparator() ne $self->PackageSeparator())
253
+ { $self->[PACKAGE_SEPARATOR] = '.'; };
254
+ };
255
+ }
256
+
257
+ # If there's more than one package...
258
+ else
259
+ {
260
+ # See if the new package is one of them.
261
+ my $selfPackages = $self->Package();
262
+ my $matchingPackage;
263
+
264
+ foreach my $testPackage (@$selfPackages)
265
+ {
266
+ if ($package eq $testPackage->Package())
267
+ {
268
+ $testPackage->MergeFile($file, $type, $prototype, $summary);;
269
+ return;
270
+ };
271
+ };
272
+
273
+ my $newDefinition = NaturalDocs::SymbolTable::IndexElement->New(undef, $package, $file, $type, $prototype,
274
+ $summary);
275
+ push @{$self->[PACKAGE]}, $newDefinition;
276
+
277
+ if ($newDefinition->Type() ne $self->CombinedType())
278
+ { $self->[COMBINED_TYPE] = ::TOPIC_GENERAL(); };
279
+ if ($newDefinition->PackageSeparator() ne $self->PackageSeparator())
280
+ { $self->[PACKAGE_SEPARATOR] = '.'; };
281
+ };
282
+ };
283
+
284
+
285
+ #
286
+ # Function: Sort
287
+ #
288
+ # Sorts the package and file lists of the symbol.
289
+ #
290
+ sub Sort
291
+ {
292
+ my $self = shift;
293
+
294
+ if ($self->HasMultipleFiles())
295
+ {
296
+ @{$self->[FILE]} = sort { ::StringCompare($a->File(), $b->File()) } @{$self->File()};
297
+ }
298
+
299
+ elsif ($self->HasMultiplePackages())
300
+ {
301
+ @{$self->[PACKAGE]} = sort { ::StringCompare( $a->Package(), $b->Package()) } @{$self->[PACKAGE]};
302
+
303
+ foreach my $packageElement ( @{$self->[PACKAGE]} )
304
+ {
305
+ if ($packageElement->HasMultipleFiles())
306
+ { $packageElement->Sort(); };
307
+ };
308
+ };
309
+ };
310
+
311
+
312
+ #
313
+ # Function: MakeSortableSymbol
314
+ #
315
+ # Generates <SortableSymbol()> and <IgnoredPrefix()>. Should only be called after everything is merged.
316
+ #
317
+ sub MakeSortableSymbol
318
+ {
319
+ my $self = shift;
320
+
321
+ my $finalLanguage;
322
+
323
+ if ($self->HasMultiplePackages() || $self->HasMultipleFiles())
324
+ {
325
+ # Collect all the files that define this symbol.
326
+
327
+ my @files;
328
+
329
+ if ($self->HasMultipleFiles())
330
+ {
331
+ my $fileElements = $self->File();
332
+
333
+ foreach my $fileElement (@$fileElements)
334
+ { push @files, $fileElement->File(); };
335
+ }
336
+ else # HasMultiplePackages
337
+ {
338
+ my $packages = $self->Package();
339
+
340
+ foreach my $package (@$packages)
341
+ {
342
+ if ($package->HasMultipleFiles())
343
+ {
344
+ my $fileElements = $package->File();
345
+
346
+ foreach my $fileElement (@$fileElements)
347
+ { push @files, $fileElement->File(); };
348
+ }
349
+ else
350
+ { push @files, $package->File(); };
351
+ };
352
+ };
353
+
354
+
355
+ # Determine which language defines it the most.
356
+
357
+ # Keys are language objects, values are counts.
358
+ my %languages;
359
+ tie %languages, 'Tie::RefHash';
360
+
361
+ foreach my $file (@files)
362
+ {
363
+ my $language = NaturalDocs::Languages->LanguageOf($file);
364
+
365
+ if (exists $languages{$language})
366
+ { $languages{$language}++; }
367
+ else
368
+ { $languages{$language} = 1; };
369
+ };
370
+
371
+ my $topCount = 0;
372
+ my @topLanguages;
373
+
374
+ while (my ($language, $count) = each %languages)
375
+ {
376
+ if ($count > $topCount)
377
+ {
378
+ $topCount = $count;
379
+ @topLanguages = ( $language );
380
+ }
381
+ elsif ($count == $topCount)
382
+ {
383
+ push @topLanguages, $language;
384
+ };
385
+ };
386
+
387
+ if (scalar @topLanguages == 1)
388
+ { $finalLanguage = $topLanguages[0]; }
389
+ else
390
+ {
391
+ if ($topLanguages[0]->Name() ne 'Text File')
392
+ { $finalLanguage = $topLanguages[0]; }
393
+ else
394
+ { $finalLanguage = $topLanguages[1]; };
395
+ };
396
+ }
397
+
398
+ else # !hasMultiplePackages && !hasMultipleFiles
399
+ { $finalLanguage = NaturalDocs::Languages->LanguageOf($self->File()); };
400
+
401
+ my $textSymbol = NaturalDocs::SymbolString->ToText($self->Symbol(), $self->PackageSeparator());
402
+ my $ignoredPrefixLength = $finalLanguage->IgnoredPrefixLength($textSymbol, $self->CombinedType());
403
+
404
+ if ($ignoredPrefixLength)
405
+ {
406
+ $self->[IGNORED_PREFIX] = substr($textSymbol, 0, $ignoredPrefixLength);
407
+ $self->[SORTABLE_SYMBOL] = substr($textSymbol, $ignoredPrefixLength);
408
+ }
409
+ else
410
+ { $self->[SORTABLE_SYMBOL] = $textSymbol; };
411
+ };
412
+
413
+
414
+
415
+ ###############################################################################
416
+ #
417
+ # Functions: Information Functions
418
+ #
419
+ # Symbol - Returns the <SymbolString> without the package portion.
420
+ # Package - If <HasMultiplePackages()> is true, returns an arrayref of <NaturalDocs::SymbolTable::IndexElement> objects.
421
+ # Otherwise returns the package <SymbolString>, or undef if global.
422
+ # File - If <HasMultipleFiles()> is true, returns an arrayref of <NaturalDocs::SymbolTable::IndexElement> objects. Otherwise
423
+ # returns the name of the definition file.
424
+ # Type - Returns the <TopicType> of the package/symbol/file, if applicable.
425
+ # Prototype - Returns the prototype of the package/symbol/file, if applicable.
426
+ # Summary - Returns the summary of the package/symbol/file, if applicable.
427
+ # CombinedType - Returns the combined <TopicType> of the element.
428
+ # PackageSeparator - Returns the combined package separator symbol of the element.
429
+ # SortableSymbol - Returns the sortable symbol as a text string. Only available after calling <MakeSortableSymbol()>.
430
+ # IgnoredPrefix - Returns the part of the symbol that was stripped off to make the <SortableSymbol()>, or undef if none.
431
+ # Only available after calling <MakeSortableSymbol()>.
432
+ #
433
+
434
+ # Function: HasMultiplePackages
435
+ # Returns whether <Packages()> is broken out into more elements.
436
+ sub HasMultiplePackages
437
+ { return ref($_[0]->[PACKAGE]); };
438
+
439
+ # Function: HasMultipleFiles
440
+ # Returns whether <File()> is broken out into more elements.
441
+ sub HasMultipleFiles
442
+ { return ref($_[0]->[FILE]); };
443
+
444
+
445
+
446
+
447
+
448
+
449
+ ###############################################################################
450
+ # Group: Support Functions
451
+
452
+ #
453
+ # Function: MergeFile
454
+ #
455
+ # Adds another definition of the same package/symbol. Perhaps the file is different.
456
+ #
457
+ # Parameters:
458
+ #
459
+ # file - The package/symbol's definition file.
460
+ # type - The package/symbol's <TopicType>.
461
+ # prototype - The package/symbol's protoype if applicable.
462
+ # summary - The package/symbol's summary if applicable.
463
+ #
464
+ sub MergeFile #(file, type, prototype, summary)
465
+ {
466
+ my ($self, $file, $type, $prototype, $summary) = @_;
467
+
468
+ # If there's only one file...
469
+ if (!$self->HasMultipleFiles())
470
+ {
471
+ # If there's one file and it's the different from the new one...
472
+ if ($file ne $self->File())
473
+ {
474
+ my $selfDefinition = NaturalDocs::SymbolTable::IndexElement->New(undef, undef, $self->File(), $self->Type(),
475
+ $self->Prototype(), $self->Summary(),
476
+ $self->CombinedType(),
477
+ $self->PackageSeparator());
478
+ my $newDefinition = NaturalDocs::SymbolTable::IndexElement->New(undef, undef, $file, $type, $prototype,
479
+ $summary);
480
+
481
+ $self->[FILE] = [ $selfDefinition, $newDefinition ];
482
+ $self->[TYPE] = undef;
483
+ $self->[PROTOTYPE] = undef;
484
+ $self->[SUMMARY] = undef;
485
+
486
+ if ($newDefinition->Type() ne $self->CombinedType())
487
+ { $self->[COMBINED_TYPE] = ::TOPIC_GENERAL(); };
488
+ if ($newDefinition->PackageSeparator() ne $self->PackageSeparator())
489
+ { $self->[PACKAGE_SEPARATOR] = '.'; };
490
+ }
491
+
492
+ # If the file was the same, just ignore the duplicate in the index.
493
+ }
494
+
495
+ # If there's more than one file...
496
+ else
497
+ {
498
+ # See if the new file is one of them.
499
+ my $files = $self->File();
500
+
501
+ foreach my $testElement (@$files)
502
+ {
503
+ if ($testElement->File() eq $file)
504
+ {
505
+ # If the new file's already in the index, ignore the duplicate.
506
+ return;
507
+ };
508
+ };
509
+
510
+ my $newDefinition = NaturalDocs::SymbolTable::IndexElement->New(undef, undef, $file, $type, $prototype,
511
+ $summary);
512
+ push @{$self->[FILE]}, $newDefinition;
513
+
514
+ if ($newDefinition->Type() ne $self->CombinedType())
515
+ { $self->[COMBINED_TYPE] = ::TOPIC_GENERAL(); };
516
+ if ($newDefinition->PackageSeparator() ne $self->PackageSeparator())
517
+ { $self->[PACKAGE_SEPARATOR] = '.'; };
518
+ };
519
+ };
520
+
521
+
522
+ 1;