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,1418 @@
1
+ ###############################################################################
2
+ #
3
+ # Package: NaturalDocs::Settings
4
+ #
5
+ ###############################################################################
6
+ #
7
+ # A package to handle the command line and various other program settings.
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 Cwd ();
15
+
16
+ use NaturalDocs::Settings::BuildTarget;
17
+
18
+ use strict;
19
+ use integer;
20
+
21
+ package NaturalDocs::Settings;
22
+
23
+
24
+ ###############################################################################
25
+ # Group: Information
26
+
27
+ =pod begin nd
28
+
29
+ Topic: Usage and Dependencies
30
+
31
+ - The <Constant Functions> can be called immediately.
32
+
33
+ - Prior to initialization, <NaturalDocs::Builder> must have all its output packages registered.
34
+
35
+ - To initialize, call <Load()>. All functions except <InputDirectoryNameOf()> will then be available.
36
+
37
+ - <GenerateDirectoryNames()> must be called before <InputDirectoryNameOf()> will work. Currently it is called by
38
+ <NaturalDocs::Menu->LoadAndUpdate()>.
39
+
40
+
41
+ Architecture: Internal Overview
42
+
43
+ - <Load()> first parses the command line, gathering all the settings and checking for errors. All <NaturalDocs::Builder>
44
+ packages must be registered before this is called because it needs their command line options.
45
+ <NaturalDocs::Project->ReparseEverything()> and <NaturalDocs::Project->RebuildEverything()> are called right away if -r
46
+ or -ro are used.
47
+
48
+ - Output directories are *not* named at this point. See <Named Directories>.
49
+
50
+ - The previous settings from the last time Natural Docs was run are loaded and compared to the current settings.
51
+ <NaturalDocs::Project->ReparseEverything()> and <NaturalDocs::Project->RebuildEverything()> are called if there are
52
+ any differences that warrant it.
53
+
54
+ - It then waits for <GenerateDirectoryNames()> to be called by <NaturalDocs::Menu>. The reason for this is that the
55
+ previous directory names are stored as hints in the menu file, for reasons explained in <Named Directories>. Once that
56
+ happens all the unnamed directories have names generated for them so everything is named. The package is completely
57
+ set up.
58
+
59
+ - The input directories are stored in an array instead of a hash because the order they were declared in matters. If two
60
+ people use multiple input directories on separate computers without sharing a menu file, they should at least get consistent
61
+ directory names by declaring them in the same order.
62
+
63
+
64
+ Architecture: Named Directories
65
+
66
+ Ever since Natural Docs introduced multiple input directories in 1.16, they've had to be named. Since they don't necessarily
67
+ extend from the same root anymore, they can't share an output directory without the risk of file name conflicts. There was
68
+ an early attempt at giving them actual names, but now they're just numbered from 1.
69
+
70
+ Directory names aren't generated right away. It waits for <Menu.txt> to load because that holds the obfuscated names from
71
+ the last run. <NaturalDocs::Menu> then calls <GenerateDirectoryNames()> and passes those along as hints.
72
+ <GenerateDirectoryNames()> then applies them to any matches and generates new ones for any remaining. This is done so
73
+ that output page locations can remain consistent when built on multiple computers, so long as the menu file is shared. I tend
74
+ to think the menu file is the most likely configuration file to be shared.
75
+
76
+
77
+ Architecture: Removed Directories
78
+
79
+ Directories that were part of the previous run but aren't anymore are still stored in the package. The primary reason, though
80
+ there may be others, is file purging. If an input directory is removed, all the output files that were generated from anything
81
+ in it need to be removed. To find out what the output file name was for a removed source file, it needs to be able to split it
82
+ from it's original input directory and know what that directory was named. If this didn't happen those output files would be
83
+ orphaned, as was the case prior to 1.32.
84
+
85
+ =cut
86
+
87
+
88
+
89
+ ###############################################################################
90
+ # Group: Variables
91
+
92
+
93
+ # handle: PREVIOUS_SETTINGS_FILEHANDLE
94
+ # The file handle used with <PreviousSettings.nd>.
95
+
96
+ # array: inputDirectories
97
+ # An array of input directories.
98
+ my @inputDirectories;
99
+
100
+ # array: inputDirectoryNames
101
+ # An array of the input directory names. Each name corresponds to the directory of the same index in <inputDirectories>.
102
+ my @inputDirectoryNames;
103
+
104
+ # array: imageDirectories
105
+ # An array of image directories.
106
+ my @imageDirectories;
107
+
108
+ # array: imageDirectoryNames
109
+ # An array of the image directory names. Each name corresponds to the directory of the same index in <imageDirectories>.
110
+ my @imageDirectoryNames;
111
+
112
+ # array: relativeImageDirectories
113
+ # An array of the relative paths for images. The asterisks found in the command line are not present.
114
+ my @relativeImageDirectories;
115
+
116
+ # array: excludedInputDirectories
117
+ # An array of input directories to exclude.
118
+ my @excludedInputDirectories;
119
+
120
+ # array: removedInputDirectories
121
+ # An array of input directories that were once in the command line but are no longer.
122
+ my @removedInputDirectories;
123
+
124
+ # array: removedInputDirectoryNames
125
+ # An array of the removed input directories' names. Each name corresponds to the directory of the same index in
126
+ # <removedInputDirectories>.
127
+ my @removedInputDirectoryNames;
128
+
129
+ # array: removedImageDirectories
130
+ # An array of image directories that were once in the command line but are no longer.
131
+ my @removedImageDirectories;
132
+
133
+ # array: removedImageDirectoryNames
134
+ # An array of the removed image directories' names. Each name corresponds to the directory of the same index in
135
+ # <removedImageDirectories>.
136
+ my @removedImageDirectoryNames;
137
+
138
+ # var: projectDirectory
139
+ # The project directory.
140
+ my $projectDirectory;
141
+
142
+ # array: buildTargets
143
+ # An array of <NaturalDocs::Settings::BuildTarget>s.
144
+ my @buildTargets;
145
+
146
+ # var: documentedOnly
147
+ # Whether undocumented code aspects should be included in the output.
148
+ my $documentedOnly;
149
+
150
+ # int: tabLength
151
+ # The number of spaces in tabs.
152
+ my $tabLength;
153
+
154
+ # bool: noAutoGroup
155
+ # Whether auto-grouping is turned off.
156
+ my $noAutoGroup;
157
+
158
+ # bool: onlyFileTitles
159
+ # Whether source files should always use the file name as the title.
160
+ my $onlyFileTitles;
161
+
162
+ # bool: isQuiet
163
+ # Whether the script should be run in quiet mode or not.
164
+ my $isQuiet;
165
+
166
+ # bool: rebuildData
167
+ # WHether most data files should be ignored and rebuilt.
168
+ my $rebuildData;
169
+
170
+ # array: styles
171
+ # An array of style names to use, most important first.
172
+ my @styles;
173
+
174
+ # var: charset
175
+ # The character encoding of the source files, and thus the output.
176
+ my $charset;
177
+
178
+
179
+ ###############################################################################
180
+ # Group: Files
181
+
182
+
183
+ #
184
+ # File: PreviousSettings.nd
185
+ #
186
+ # Stores the previous command line settings.
187
+ #
188
+ # Format:
189
+ #
190
+ # > [BINARY_FORMAT]
191
+ # > [VersionInt: app version]
192
+ #
193
+ # The file starts with the standard <BINARY_FORMAT> <VersionInt> header.
194
+ #
195
+ # > [UInt8: tab length]
196
+ # > [UInt8: documented only (0 or 1)]
197
+ # > [UInt8: no auto-group (0 or 1)]
198
+ # > [UInt8: only file titles (0 or 1)]
199
+ # > [AString16: charset]
200
+ # >
201
+ # > [UInt8: number of input directories]
202
+ # > [AString16: input directory] [AString16: input directory name] ...
203
+ #
204
+ # A count of input directories, then that number of directory/name pairs.
205
+ #
206
+ # > [UInt8: number of output targets]
207
+ # > [AString16: output directory] [AString16: output format command line option] ...
208
+ #
209
+ # A count of output targets, then that number of directory/format pairs.
210
+ #
211
+ #
212
+ # Revisions:
213
+ #
214
+ # 1.4:
215
+ #
216
+ # - Added only file titles.
217
+ #
218
+ # 1.33:
219
+ #
220
+ # - Added charset.
221
+ #
222
+ # 1.3:
223
+ #
224
+ # - Removed headers-only, which was a 0/1 UInt8 after tab length.
225
+ # - Change auto-group level (1 = no, 2 = yes, 3 = full only) to no auto-group (0 or 1).
226
+ #
227
+ # 1.22:
228
+ #
229
+ # - Added auto-group level.
230
+ #
231
+ # 1.2:
232
+ #
233
+ # - File was added to the project. Prior to 1.2, it didn't exist.
234
+ #
235
+
236
+
237
+ ###############################################################################
238
+ # Group: Action Functions
239
+
240
+ #
241
+ # Function: Load
242
+ #
243
+ # Loads and parses all settings from the command line and configuration files. Will exit if the options are invalid or the syntax
244
+ # reference was requested.
245
+ #
246
+ sub Load
247
+ {
248
+ my ($self) = @_;
249
+
250
+ $self->ParseCommandLine();
251
+ $self->LoadAndComparePreviousSettings();
252
+ };
253
+
254
+
255
+ #
256
+ # Function: Save
257
+ #
258
+ # Saves all settings in configuration files to disk.
259
+ #
260
+ sub Save
261
+ {
262
+ my ($self) = @_;
263
+
264
+ $self->SavePreviousSettings();
265
+ };
266
+
267
+
268
+ #
269
+ # Function: GenerateDirectoryNames
270
+ #
271
+ # Generates names for each of the input and image directories, which can later be retrieved with <InputDirectoryNameOf()>
272
+ # and <ImageDirectoryNameOf()>.
273
+ #
274
+ # Parameters:
275
+ #
276
+ # inputHints - A hashref of suggested input directory names, where the keys are the directories and the values are the names.
277
+ # These take precedence over anything generated. You should include names for directories that are no longer in
278
+ # the command line. This parameter may be undef.
279
+ # imageHints - Same as inputHints, only for the image directories.
280
+ #
281
+ sub GenerateDirectoryNames #(hashref inputHints, hashref imageHints)
282
+ {
283
+ my ($self, $inputHints, $imageHints) = @_;
284
+
285
+ my %usedInputNames;
286
+ my %usedImageNames;
287
+
288
+
289
+ if (defined $inputHints)
290
+ {
291
+ # First, we have to convert all non-numeric names to numbers, since they may come from a pre-1.32 menu file. We do it
292
+ # here instead of in NaturalDocs::Menu to keep the naming scheme centralized.
293
+
294
+ my @names = values %$inputHints;
295
+ my $hasNonNumeric;
296
+
297
+ foreach my $name (@names)
298
+ {
299
+ if ($name !~ /^[0-9]+$/)
300
+ {
301
+ $hasNonNumeric = 1;
302
+ last;
303
+ };
304
+ };
305
+
306
+
307
+ if ($hasNonNumeric)
308
+ {
309
+ # Hash mapping old names to new names.
310
+ my %conversion;
311
+
312
+ # The sequential number to use. Starts at two because we want 'default' to be one.
313
+ my $currentNumber = 2;
314
+
315
+ # If there's only one name, we set it to one no matter what it was set to before.
316
+ if (scalar @names == 1)
317
+ { $conversion{$names[0]} = 1; }
318
+ else
319
+ {
320
+ # We sort the list first because we want the end result to be predictable. This conversion could be happening on many
321
+ # machines, and they may not all specify the input directories in the same order. They need to all come up with the
322
+ # same result.
323
+ @names = sort @names;
324
+
325
+ foreach my $name (@names)
326
+ {
327
+ if ($name eq 'default')
328
+ { $conversion{$name} = 1; }
329
+ else
330
+ {
331
+ $conversion{$name} = $currentNumber;
332
+ $currentNumber++;
333
+ };
334
+ };
335
+ };
336
+
337
+ # Convert them to the new names.
338
+ foreach my $directory (keys %$inputHints)
339
+ {
340
+ $inputHints->{$directory} = $conversion{ $inputHints->{$directory} };
341
+ };
342
+ };
343
+
344
+
345
+ # Now we apply all the names from the hints, and save any unused ones as removed directories.
346
+
347
+ for (my $i = 0; $i < scalar @inputDirectories; $i++)
348
+ {
349
+ if (exists $inputHints->{$inputDirectories[$i]})
350
+ {
351
+ $inputDirectoryNames[$i] = $inputHints->{$inputDirectories[$i]};
352
+ $usedInputNames{ $inputDirectoryNames[$i] } = 1;
353
+ delete $inputHints->{$inputDirectories[$i]};
354
+ };
355
+ };
356
+
357
+
358
+ # Any remaining hints are saved as removed directories.
359
+
360
+ while (my ($directory, $name) = each %$inputHints)
361
+ {
362
+ push @removedInputDirectories, $directory;
363
+ push @removedInputDirectoryNames, $name;
364
+ };
365
+ };
366
+
367
+
368
+ if (defined $imageHints)
369
+ {
370
+ # Image directory names were never non-numeric, so there is no conversion. Apply all the names from the hints.
371
+
372
+ for (my $i = 0; $i < scalar @imageDirectories; $i++)
373
+ {
374
+ if (exists $imageHints->{$imageDirectories[$i]})
375
+ {
376
+ $imageDirectoryNames[$i] = $imageHints->{$imageDirectories[$i]};
377
+ $usedImageNames{ $imageDirectoryNames[$i] } = 1;
378
+ delete $imageHints->{$imageDirectories[$i]};
379
+ };
380
+ };
381
+
382
+
383
+ # Any remaining hints are saved as removed directories.
384
+
385
+ while (my ($directory, $name) = each %$imageHints)
386
+ {
387
+ push @removedImageDirectories, $directory;
388
+ push @removedImageDirectoryNames, $name;
389
+ };
390
+ };
391
+
392
+
393
+ # Now we generate names for anything remaining.
394
+
395
+ my $inputCounter = 1;
396
+
397
+ for (my $i = 0; $i < scalar @inputDirectories; $i++)
398
+ {
399
+ if (!defined $inputDirectoryNames[$i])
400
+ {
401
+ while (exists $usedInputNames{$inputCounter})
402
+ { $inputCounter++; };
403
+
404
+ $inputDirectoryNames[$i] = $inputCounter;
405
+ $usedInputNames{$inputCounter} = 1;
406
+
407
+ $inputCounter++;
408
+ };
409
+ };
410
+
411
+
412
+ my $imageCounter = 1;
413
+
414
+ for (my $i = 0; $i < scalar @imageDirectories; $i++)
415
+ {
416
+ if (!defined $imageDirectoryNames[$i])
417
+ {
418
+ while (exists $usedImageNames{$imageCounter})
419
+ { $imageCounter++; };
420
+
421
+ $imageDirectoryNames[$i] = $imageCounter;
422
+ $usedImageNames{$imageCounter} = 1;
423
+
424
+ $imageCounter++;
425
+ };
426
+ };
427
+ };
428
+
429
+
430
+
431
+ ###############################################################################
432
+ # Group: Information Functions
433
+
434
+
435
+ #
436
+ # Function: InputDirectories
437
+ #
438
+ # Returns an arrayref of input directories. Do not change.
439
+ #
440
+ # This will not return any removed input directories.
441
+ #
442
+ sub InputDirectories
443
+ { return \@inputDirectories; };
444
+
445
+ #
446
+ # Function: InputDirectoryNameOf
447
+ #
448
+ # Returns the generated name of the passed input directory. <GenerateDirectoryNames()> must be called once before this
449
+ # function is available.
450
+ #
451
+ # If a name for a removed input directory is available, it will be returned as well.
452
+ #
453
+ sub InputDirectoryNameOf #(directory)
454
+ {
455
+ my ($self, $directory) = @_;
456
+
457
+ for (my $i = 0; $i < scalar @inputDirectories; $i++)
458
+ {
459
+ if ($directory eq $inputDirectories[$i])
460
+ { return $inputDirectoryNames[$i]; };
461
+ };
462
+
463
+ for (my $i = 0; $i < scalar @removedInputDirectories; $i++)
464
+ {
465
+ if ($directory eq $removedInputDirectories[$i])
466
+ { return $removedInputDirectoryNames[$i]; };
467
+ };
468
+
469
+ return undef;
470
+ };
471
+
472
+
473
+ #
474
+ # Function: SplitFromInputDirectory
475
+ #
476
+ # Takes an input file name and returns the array ( inputDirectory, relativePath ).
477
+ #
478
+ # If the file cannot be split from an input directory, it will try to do it with the removed input directories.
479
+ #
480
+ sub SplitFromInputDirectory #(file)
481
+ {
482
+ my ($self, $file) = @_;
483
+
484
+ foreach my $directory (@inputDirectories, @removedInputDirectories)
485
+ {
486
+ if (NaturalDocs::File->IsSubPathOf($directory, $file))
487
+ { return ( $directory, NaturalDocs::File->MakeRelativePath($directory, $file) ); };
488
+ };
489
+
490
+ return ( );
491
+ };
492
+
493
+
494
+ #
495
+ # Function: ImageDirectories
496
+ #
497
+ # Returns an arrayref of image directories. Do not change.
498
+ #
499
+ # This will not return any removed image directories.
500
+ #
501
+ sub ImageDirectories
502
+ { return \@imageDirectories; };
503
+
504
+
505
+ #
506
+ # Function: ImageDirectoryNameOf
507
+ #
508
+ # Returns the generated name of the passed image or input directory. <GenerateDirectoryNames()> must be called once before
509
+ # this function is available.
510
+ #
511
+ # If a name for a removed input or image directory is available, it will be returned as well.
512
+ #
513
+ sub ImageDirectoryNameOf #(directory)
514
+ {
515
+ my ($self, $directory) = @_;
516
+
517
+ for (my $i = 0; $i < scalar @imageDirectories; $i++)
518
+ {
519
+ if ($directory eq $imageDirectories[$i])
520
+ { return $imageDirectoryNames[$i]; };
521
+ };
522
+
523
+ for (my $i = 0; $i < scalar @removedImageDirectories; $i++)
524
+ {
525
+ if ($directory eq $removedImageDirectories[$i])
526
+ { return $removedImageDirectoryNames[$i]; };
527
+ };
528
+
529
+ return undef;
530
+ };
531
+
532
+
533
+ #
534
+ # Function: SplitFromImageDirectory
535
+ #
536
+ # Takes an input image file name and returns the array ( imageDirectory, relativePath ).
537
+ #
538
+ # If the file cannot be split from an image directory, it will try to do it with the removed image directories.
539
+ #
540
+ sub SplitFromImageDirectory #(file)
541
+ {
542
+ my ($self, $file) = @_;
543
+
544
+ foreach my $directory (@imageDirectories, @removedImageDirectories)
545
+ {
546
+ if (NaturalDocs::File->IsSubPathOf($directory, $file))
547
+ { return ( $directory, NaturalDocs::File->MakeRelativePath($directory, $file) ); };
548
+ };
549
+
550
+ return ( );
551
+ };
552
+
553
+
554
+ #
555
+ # Function: RelativeImageDirectories
556
+ #
557
+ # Returns an arrayref of relative image directories. Do not change.
558
+ #
559
+ sub RelativeImageDirectories
560
+ { return \@relativeImageDirectories; };
561
+
562
+
563
+ # Function: ExcludedInputDirectories
564
+ # Returns an arrayref of input directories to exclude. Do not change.
565
+ sub ExcludedInputDirectories
566
+ { return \@excludedInputDirectories; };
567
+
568
+
569
+ # Function: BuildTargets
570
+ # Returns an arrayref of <NaturalDocs::Settings::BuildTarget>s. Do not change.
571
+ sub BuildTargets
572
+ { return \@buildTargets; };
573
+
574
+
575
+ #
576
+ # Function: OutputDirectoryOf
577
+ #
578
+ # Returns the output directory of a builder object.
579
+ #
580
+ # Parameters:
581
+ #
582
+ # object - The builder object, whose class is derived from <NaturalDocs::Builder::Base>.
583
+ #
584
+ # Returns:
585
+ #
586
+ # The builder directory, or undef if the object wasn't found..
587
+ #
588
+ sub OutputDirectoryOf #(object)
589
+ {
590
+ my ($self, $object) = @_;
591
+
592
+ foreach my $buildTarget (@buildTargets)
593
+ {
594
+ if ($buildTarget->Builder() == $object)
595
+ { return $buildTarget->Directory(); };
596
+ };
597
+
598
+ return undef;
599
+ };
600
+
601
+
602
+ # Function: Styles
603
+ # Returns an arrayref of the styles associated with the output.
604
+ sub Styles
605
+ { return \@styles; };
606
+
607
+ # Function: ProjectDirectory
608
+ # Returns the project directory.
609
+ sub ProjectDirectory
610
+ { return $projectDirectory; };
611
+
612
+ # Function: ProjectDataDirectory
613
+ # Returns the project data directory.
614
+ sub ProjectDataDirectory
615
+ { return NaturalDocs::File->JoinPaths($projectDirectory, 'Data', 1); };
616
+
617
+ # Function: StyleDirectory
618
+ # Returns the main style directory.
619
+ sub StyleDirectory
620
+ { return NaturalDocs::File->JoinPaths($FindBin::RealBin, 'Styles', 1); };
621
+
622
+ # Function: JavaScriptDirectory
623
+ # Returns the main JavaScript directory.
624
+ sub JavaScriptDirectory
625
+ { return NaturalDocs::File->JoinPaths($FindBin::RealBin, 'JavaScript', 1); };
626
+
627
+ # Function: ConfigDirectory
628
+ # Returns the main configuration directory.
629
+ sub ConfigDirectory
630
+ { return NaturalDocs::File->JoinPaths($FindBin::RealBin, 'Config', 1); };
631
+
632
+ # Function: DocumentedOnly
633
+ # Returns whether undocumented code aspects should be included in the output.
634
+ sub DocumentedOnly
635
+ { return $documentedOnly; };
636
+
637
+ # Function: TabLength
638
+ # Returns the number of spaces tabs should be expanded to.
639
+ sub TabLength
640
+ { return $tabLength; };
641
+
642
+ # Function: NoAutoGroup
643
+ # Returns whether auto-grouping is turned off.
644
+ sub NoAutoGroup
645
+ { return $noAutoGroup; };
646
+
647
+ # Function: OnlyFileTitles
648
+ # Returns whether source files should always use the file name as the title.
649
+ sub OnlyFileTitles
650
+ { return $onlyFileTitles; };
651
+
652
+ # Function: IsQuiet
653
+ # Returns whether the script should be run in quiet mode or not.
654
+ sub IsQuiet
655
+ { return $isQuiet; };
656
+
657
+ # Function: RebuildData
658
+ # Returns whether all data files should be ignored and rebuilt.
659
+ sub RebuildData
660
+ { return $rebuildData; };
661
+
662
+ # Function: CharSet
663
+ # Returns the character set, or undef if none.
664
+ sub CharSet
665
+ { return $charset; };
666
+
667
+
668
+ ###############################################################################
669
+ # Group: Constant Functions
670
+
671
+ #
672
+ # Function: AppVersion
673
+ #
674
+ # Returns Natural Docs' version number as an integer. Use <TextAppVersion()> to get a printable version.
675
+ #
676
+ sub AppVersion
677
+ {
678
+ my ($self) = @_;
679
+ return NaturalDocs::Version->FromString($self->TextAppVersion());
680
+ };
681
+
682
+ #
683
+ # Function: TextAppVersion
684
+ #
685
+ # Returns Natural Docs' version number as plain text.
686
+ #
687
+ sub TextAppVersion
688
+ {
689
+ return '1.4';
690
+ };
691
+
692
+ #
693
+ # Function: AppURL
694
+ #
695
+ # Returns a string of the project's current web address.
696
+ #
697
+ sub AppURL
698
+ { return 'http://www.naturaldocs.org'; };
699
+
700
+
701
+
702
+ ###############################################################################
703
+ # Group: Support Functions
704
+
705
+
706
+ #
707
+ # Function: ParseCommandLine
708
+ #
709
+ # Parses and validates the command line. Will cause the script to exit if the options ask for the syntax reference or
710
+ # are invalid.
711
+ #
712
+ sub ParseCommandLine
713
+ {
714
+ my ($self) = @_;
715
+
716
+ my %synonyms = ( 'input' => '-i',
717
+ 'source' => '-i',
718
+ 'excludeinput' => '-xi',
719
+ 'excludesource' => '-xi',
720
+ 'images' => '-img',
721
+ 'output' => '-o',
722
+ 'project' => '-p',
723
+ 'documentedonly' => '-do',
724
+ 'style' => '-s',
725
+ 'rebuild' => '-r',
726
+ 'rebuildoutput' => '-ro',
727
+ 'tablength' => '-t',
728
+ 'quiet' => '-q',
729
+ 'headersonly' => '-ho',
730
+ 'help' => '-h',
731
+ 'autogroup' => '-ag',
732
+ 'noautogroup' => '-nag',
733
+ 'onlyfiletitles' => '-oft',
734
+ 'onlyfiletitle' => '-oft',
735
+ 'charset' => '-cs',
736
+ 'characterset' => '-cs' );
737
+
738
+
739
+ my @errorMessages;
740
+
741
+ my $valueRef;
742
+ my $option;
743
+
744
+ my @outputStrings;
745
+ my @imageStrings;
746
+
747
+
748
+ # Sometimes $valueRef is set to $ignored instead of undef because we don't want certain errors to cause other,
749
+ # unnecessary errors. For example, if they set the input directory twice, we want to show that error and swallow the
750
+ # specified directory without complaint. Otherwise it would complain about the directory too as if it were random crap
751
+ # inserted into the command line.
752
+ my $ignored;
753
+
754
+ my $index = 0;
755
+
756
+ while ($index < scalar @ARGV)
757
+ {
758
+ my $arg = $ARGV[$index];
759
+
760
+ if (substr($arg, 0, 1) eq '-')
761
+ {
762
+ $option = lc($arg);
763
+
764
+ # Support options like -t2 as well as -t 2.
765
+ if ($option =~ /^([^0-9]+)([0-9]+)$/)
766
+ {
767
+ $option = $1;
768
+ splice(@ARGV, $index + 1, 0, $2);
769
+ };
770
+
771
+ # Convert long forms to short.
772
+ if (substr($option, 1, 1) eq '-')
773
+ {
774
+ # Strip all dashes.
775
+ my $newOption = $option;
776
+ $newOption =~ tr/-//d;
777
+
778
+ if (exists $synonyms{$newOption})
779
+ { $option = $synonyms{$newOption}; }
780
+ }
781
+
782
+ if ($option eq '-i')
783
+ {
784
+ push @inputDirectories, undef;
785
+ $valueRef = \$inputDirectories[-1];
786
+ }
787
+ elsif ($option eq '-xi')
788
+ {
789
+ push @excludedInputDirectories, undef;
790
+ $valueRef = \$excludedInputDirectories[-1];
791
+ }
792
+ elsif ($option eq '-img')
793
+ {
794
+ push @imageStrings, undef;
795
+ $valueRef = \$imageStrings[-1];
796
+ }
797
+ elsif ($option eq '-p')
798
+ {
799
+ if (defined $projectDirectory)
800
+ {
801
+ push @errorMessages, 'You cannot have more than one project directory.';
802
+ $valueRef = \$ignored;
803
+ }
804
+ else
805
+ { $valueRef = \$projectDirectory; };
806
+ }
807
+ elsif ($option eq '-o')
808
+ {
809
+ push @outputStrings, undef;
810
+ $valueRef = \$outputStrings[-1];
811
+ }
812
+ elsif ($option eq '-s')
813
+ {
814
+ $valueRef = \$styles[0];
815
+ }
816
+ elsif ($option eq '-t')
817
+ {
818
+ $valueRef = \$tabLength;
819
+ }
820
+ elsif ($option eq '-cs')
821
+ {
822
+ $valueRef = \$charset;
823
+ }
824
+ elsif ($option eq '-ag')
825
+ {
826
+ push @errorMessages, 'The -ag setting is no longer supported. You can use -nag (--no-auto-group) to turn off '
827
+ . "auto-grouping, but there aren't multiple levels anymore.";
828
+ $valueRef = \$ignored;
829
+ }
830
+
831
+ # Options that aren't followed by content.
832
+ else
833
+ {
834
+ $valueRef = undef;
835
+
836
+ if ($option eq '-r')
837
+ {
838
+ NaturalDocs::Project->ReparseEverything();
839
+ NaturalDocs::Project->RebuildEverything();
840
+ $rebuildData = 1;
841
+ }
842
+ elsif ($option eq '-ro')
843
+ {
844
+ NaturalDocs::Project->RebuildEverything();
845
+ }
846
+ elsif ($option eq '-do')
847
+ { $documentedOnly = 1; }
848
+ elsif ($option eq '-oft')
849
+ { $onlyFileTitles = 1; }
850
+ elsif ($option eq '-q')
851
+ { $isQuiet = 1; }
852
+ elsif ($option eq '-ho')
853
+ {
854
+ push @errorMessages, 'The -ho setting is no longer supported. You can have Natural Docs skip over the source file '
855
+ . 'extensions by editing Languages.txt in your project directory.';
856
+ }
857
+ elsif ($option eq '-nag')
858
+ { $noAutoGroup = 1; }
859
+ elsif ($option eq '-?' || $option eq '-h')
860
+ {
861
+ $self->PrintSyntax();
862
+ exit;
863
+ }
864
+ else
865
+ { push @errorMessages, 'Unrecognized option ' . $option; };
866
+
867
+ };
868
+
869
+ }
870
+
871
+ # Is a segment of text, not an option...
872
+ else
873
+ {
874
+ if (defined $valueRef)
875
+ {
876
+ # We want to preserve spaces in paths.
877
+ if (defined $$valueRef)
878
+ { $$valueRef .= ' '; };
879
+
880
+ $$valueRef .= $arg;
881
+ }
882
+
883
+ else
884
+ {
885
+ push @errorMessages, 'Unrecognized element ' . $arg;
886
+ };
887
+ };
888
+
889
+ $index++;
890
+ };
891
+
892
+
893
+ # Validate the style, if specified.
894
+
895
+ if ($styles[0])
896
+ {
897
+ my @stylePieces = split(/ +/, $styles[0]);
898
+ @styles = ( );
899
+
900
+ while (scalar @stylePieces)
901
+ {
902
+ if (lc($stylePieces[0]) eq 'custom')
903
+ {
904
+ push @errorMessages, 'The "Custom" style setting is no longer supported. Copy your custom style sheet to your '
905
+ . 'project directory and you can refer to it with -s.';
906
+ shift @stylePieces;
907
+ }
908
+ else
909
+ {
910
+ # People may use styles with spaces in them. If a style doesn't exist, we need to join the pieces until we find one that
911
+ # does or we run out of pieces.
912
+
913
+ my $extras = 0;
914
+ my $success;
915
+
916
+ while ($extras < scalar @stylePieces)
917
+ {
918
+ my $style;
919
+
920
+ if (!$extras)
921
+ { $style = $stylePieces[0]; }
922
+ else
923
+ { $style = join(' ', @stylePieces[0..$extras]); };
924
+
925
+ my $cssFile = NaturalDocs::File->JoinPaths( $self->StyleDirectory(), $style . '.css' );
926
+ if (-e $cssFile)
927
+ {
928
+ push @styles, $style;
929
+ splice(@stylePieces, 0, 1 + $extras);
930
+ $success = 1;
931
+ last;
932
+ }
933
+ else
934
+ {
935
+ $cssFile = NaturalDocs::File->JoinPaths( $self->ProjectDirectory(), $style . '.css' );
936
+
937
+ if (-e $cssFile)
938
+ {
939
+ push @styles, $style;
940
+ splice(@stylePieces, 0, 1 + $extras);
941
+ $success = 1;
942
+ last;
943
+ }
944
+ else
945
+ { $extras++; };
946
+ };
947
+ };
948
+
949
+ if (!$success)
950
+ {
951
+ push @errorMessages, 'The style "' . $stylePieces[0] . '" does not exist.';
952
+ shift @stylePieces;
953
+ };
954
+ };
955
+ };
956
+ }
957
+ else
958
+ { @styles = ( 'Default' ); };
959
+
960
+
961
+ # Decode and validate the output strings.
962
+
963
+ my %outputDirectories;
964
+
965
+ foreach my $outputString (@outputStrings)
966
+ {
967
+ my ($format, $directory) = split(/ /, $outputString, 2);
968
+
969
+ if (!defined $directory)
970
+ { push @errorMessages, 'The -o option needs two parameters: -o [format] [directory]'; }
971
+ else
972
+ {
973
+ if (!NaturalDocs::File->PathIsAbsolute($directory))
974
+ { $directory = NaturalDocs::File->JoinPaths(Cwd::cwd(), $directory, 1); };
975
+
976
+ $directory = NaturalDocs::File->CanonizePath($directory);
977
+
978
+ if (! -e $directory || ! -d $directory)
979
+ {
980
+ # They may have forgotten the format portion and the directory name had a space in it.
981
+ if (-e ($format . ' ' . $directory) && -d ($format . ' ' . $directory))
982
+ {
983
+ push @errorMessages, 'The -o option needs two parameters: -o [format] [directory]';
984
+ $format = undef;
985
+ }
986
+ else
987
+ { push @errorMessages, 'The output directory ' . $directory . ' does not exist.'; }
988
+ }
989
+ elsif (exists $outputDirectories{$directory})
990
+ { push @errorMessages, 'You cannot specify the output directory ' . $directory . ' more than once.'; }
991
+ else
992
+ { $outputDirectories{$directory} = 1; };
993
+
994
+ if (defined $format)
995
+ {
996
+ my $builderPackage = NaturalDocs::Builder->OutputPackageOf($format);
997
+
998
+ if (defined $builderPackage)
999
+ {
1000
+ push @buildTargets,
1001
+ NaturalDocs::Settings::BuildTarget->New($builderPackage->New(), $directory);
1002
+ }
1003
+ else
1004
+ {
1005
+ push @errorMessages, 'The output format ' . $format . ' doesn\'t exist or is not installed.';
1006
+ $valueRef = \$ignored;
1007
+ };
1008
+ };
1009
+ };
1010
+ };
1011
+
1012
+ if (!scalar @buildTargets)
1013
+ { push @errorMessages, 'You did not specify an output directory.'; };
1014
+
1015
+
1016
+ # Decode and validate the image strings.
1017
+
1018
+ foreach my $imageString (@imageStrings)
1019
+ {
1020
+ if ($imageString =~ /^ *\*/)
1021
+ {
1022
+ # The below NaturalDocs::File functions assume everything is canonized.
1023
+ $imageString = NaturalDocs::File->CanonizePath($imageString);
1024
+
1025
+ my ($volume, $directoryString) = NaturalDocs::File->SplitPath($imageString, 1);
1026
+ my @directories = NaturalDocs::File->SplitDirectories($directoryString);
1027
+
1028
+ shift @directories;
1029
+
1030
+ $directoryString = NaturalDocs::File->JoinDirectories(@directories);
1031
+ push @relativeImageDirectories, NaturalDocs::File->JoinPath($volume, $directoryString);
1032
+ }
1033
+ else
1034
+ {
1035
+ if (!NaturalDocs::File->PathIsAbsolute($imageString))
1036
+ { $imageString = NaturalDocs::File->JoinPaths(Cwd::cwd(), $imageString, 1); };
1037
+
1038
+ $imageString = NaturalDocs::File->CanonizePath($imageString);
1039
+
1040
+ if (! -e $imageString || ! -d $imageString)
1041
+ { push @errorMessages, 'The image directory ' . $imageString . ' does not exist.'; };
1042
+
1043
+ push @imageDirectories, $imageString;
1044
+ };
1045
+ };
1046
+
1047
+
1048
+ # Make sure the input and project directories are specified, canonized, and exist.
1049
+
1050
+ if (scalar @inputDirectories)
1051
+ {
1052
+ for (my $i = 0; $i < scalar @inputDirectories; $i++)
1053
+ {
1054
+ if (!NaturalDocs::File->PathIsAbsolute($inputDirectories[$i]))
1055
+ { $inputDirectories[$i] = NaturalDocs::File->JoinPaths(Cwd::cwd(), $inputDirectories[$i], 1); };
1056
+
1057
+ $inputDirectories[$i] = NaturalDocs::File->CanonizePath($inputDirectories[$i]);
1058
+
1059
+ if (! -e $inputDirectories[$i] || ! -d $inputDirectories[$i])
1060
+ { push @errorMessages, 'The input directory ' . $inputDirectories[$i] . ' does not exist.'; };
1061
+ };
1062
+ }
1063
+ else
1064
+ { push @errorMessages, 'You did not specify an input (source) directory.'; };
1065
+
1066
+ if (defined $projectDirectory)
1067
+ {
1068
+ if (!NaturalDocs::File->PathIsAbsolute($projectDirectory))
1069
+ { $projectDirectory = NaturalDocs::File->JoinPaths(Cwd::cwd(), $projectDirectory, 1); };
1070
+
1071
+ $projectDirectory = NaturalDocs::File->CanonizePath($projectDirectory);
1072
+
1073
+ if (! -e $projectDirectory || ! -d $projectDirectory)
1074
+ { push @errorMessages, 'The project directory ' . $projectDirectory . ' does not exist.'; };
1075
+
1076
+ # Create the Data subdirectory if it doesn't exist.
1077
+ NaturalDocs::File->CreatePath( NaturalDocs::File->JoinPaths($projectDirectory, 'Data', 1) );
1078
+ }
1079
+ else
1080
+ { push @errorMessages, 'You did not specify a project directory.'; };
1081
+
1082
+
1083
+ # Make sure the excluded input directories are canonized, and add the project and output directories to the list.
1084
+
1085
+ for (my $i = 0; $i < scalar @excludedInputDirectories; $i++)
1086
+ {
1087
+ if (!NaturalDocs::File->PathIsAbsolute($excludedInputDirectories[$i]))
1088
+ { $excludedInputDirectories[$i] = NaturalDocs::File->JoinPaths(Cwd::cwd(), $excludedInputDirectories[$i], 1); };
1089
+
1090
+ $excludedInputDirectories[$i] = NaturalDocs::File->CanonizePath($excludedInputDirectories[$i]);
1091
+ };
1092
+
1093
+ push @excludedInputDirectories, $projectDirectory;
1094
+
1095
+ foreach my $buildTarget (@buildTargets)
1096
+ {
1097
+ push @excludedInputDirectories, $buildTarget->Directory();
1098
+ };
1099
+
1100
+
1101
+ # Determine the tab length, and default to four if not specified.
1102
+
1103
+ if (defined $tabLength)
1104
+ {
1105
+ if ($tabLength !~ /^[0-9]+$/)
1106
+ { push @errorMessages, 'The tab length must be a number.'; };
1107
+ }
1108
+ else
1109
+ { $tabLength = 4; };
1110
+
1111
+
1112
+ # Strip any quotes off of the charset.
1113
+ $charset =~ tr/\"//d;
1114
+
1115
+
1116
+ # Exit with the error message if there was one.
1117
+
1118
+ if (scalar @errorMessages)
1119
+ {
1120
+ print join("\n", @errorMessages) . "\nType NaturalDocs -h to see the syntax reference.\n";
1121
+ exit;
1122
+ };
1123
+ };
1124
+
1125
+ #
1126
+ # Function: PrintSyntax
1127
+ #
1128
+ # Prints the syntax reference.
1129
+ #
1130
+ sub PrintSyntax
1131
+ {
1132
+ my ($self) = @_;
1133
+
1134
+ # Make sure all line lengths are under 80 characters.
1135
+
1136
+ print
1137
+
1138
+ "Natural Docs, version " . $self->TextAppVersion() . "\n"
1139
+ . $self->AppURL() . "\n"
1140
+ . "This program is licensed under the GPL\n"
1141
+ . "--------------------------------------\n"
1142
+ . "\n"
1143
+ . "Syntax:\n"
1144
+ . "\n"
1145
+ . " NaturalDocs -i [input (source) directory]\n"
1146
+ . " (-i [input (source) directory] ...)\n"
1147
+ . " -o [output format] [output directory]\n"
1148
+ . " (-o [output format] [output directory] ...)\n"
1149
+ . " -p [project directory]\n"
1150
+ . " [options]\n"
1151
+ . "\n"
1152
+ . "Examples:\n"
1153
+ . "\n"
1154
+ . " NaturalDocs -i C:\\My Project\\Source -o HTML C:\\My Project\\Docs\n"
1155
+ . " -p C:\\My Project\\Natural Docs\n"
1156
+ . " NaturalDocs -i /src/project -o HTML /doc/project\n"
1157
+ . " -p /etc/naturaldocs/project -s Small -q\n"
1158
+ . "\n"
1159
+ . "Required Parameters:\n"
1160
+ . "\n"
1161
+ . " -i [dir]\n--input [dir]\n--source [dir]\n"
1162
+ . " Specifies an input (source) directory. Required.\n"
1163
+ . " Can be specified multiple times.\n"
1164
+ . "\n"
1165
+ . " -o [fmt] [dir]\n--output [fmt] [dir]\n"
1166
+ . " Specifies an output format and directory. Required.\n"
1167
+ . " Can be specified multiple times, but only once per directory.\n"
1168
+ . " Possible output formats:\n";
1169
+
1170
+ $self->PrintOutputFormats(' - ');
1171
+
1172
+ print
1173
+ "\n"
1174
+ . " -p [dir]\n--project [dir]\n"
1175
+ . " Specifies the project directory. Required.\n"
1176
+ . " There needs to be a unique project directory for every source directory.\n"
1177
+ . "\n"
1178
+ . "Optional Parameters:\n"
1179
+ . "\n"
1180
+ . " -s [style] ([style] [style] ...)\n--style [style] ([style] [style] ...)\n"
1181
+ . " Specifies the CSS style when building HTML output. If multiple styles are\n"
1182
+ . " specified, they will all be included in the order given.\n"
1183
+ . "\n"
1184
+ . " -img [image directory]\n--image [image directory]"
1185
+ . " Specifies an image directory. Can be specified multiple times.\n"
1186
+ . " Start with * to specify a relative directory, as in -img */images.\n"
1187
+ . "\n"
1188
+ . " -do\n--documented-only\n"
1189
+ . " Specifies only documented code aspects should be included in the output.\n"
1190
+ . "\n"
1191
+ . " -t [len]\n--tab-length [len]\n"
1192
+ . " Specifies the number of spaces tabs should be expanded to. This only needs\n"
1193
+ . " to be set if you use tabs in example code and text diagrams. Defaults to 4.\n"
1194
+ . "\n"
1195
+ . " -xi [dir]\n--exclude-input [dir]\n--exclude-source [dir]\n"
1196
+ . " Excludes an input (source) directory from the documentation.\n"
1197
+ . " Automatically done for the project and output directories. Can\n"
1198
+ . " be specified multiple times.\n"
1199
+ . "\n"
1200
+ . " -nag\n--no-auto-group\n"
1201
+ . " Turns off auto-grouping completely.\n"
1202
+ . "\n"
1203
+ . " -oft\n--only-file-titles\n"
1204
+ . " Source files will only use the file name as the title.\n"
1205
+ . "\n"
1206
+ . " -r\n--rebuild\n"
1207
+ . " Rebuilds all output and data files from scratch.\n"
1208
+ . " Does not affect the menu file.\n"
1209
+ . "\n"
1210
+ . " -ro\n--rebuild-output\n"
1211
+ . " Rebuilds all output files from scratch.\n"
1212
+ . "\n"
1213
+ . " -q\n--quiet\n"
1214
+ . " Suppresses all non-error output.\n"
1215
+ . "\n"
1216
+ . " -?\n -h\n--help\n"
1217
+ . " Displays this syntax reference.\n";
1218
+ };
1219
+
1220
+
1221
+ #
1222
+ # Function: PrintOutputFormats
1223
+ #
1224
+ # Prints all the possible output formats that can be specified with -o. Each one will be placed on its own line.
1225
+ #
1226
+ # Parameters:
1227
+ #
1228
+ # prefix - Characters to prefix each one with, such as for indentation.
1229
+ #
1230
+ sub PrintOutputFormats #(prefix)
1231
+ {
1232
+ my ($self, $prefix) = @_;
1233
+
1234
+ my $outputPackages = NaturalDocs::Builder::OutputPackages();
1235
+
1236
+ foreach my $outputPackage (@$outputPackages)
1237
+ {
1238
+ print $prefix . $outputPackage->CommandLineOption() . "\n";
1239
+ };
1240
+ };
1241
+
1242
+
1243
+ #
1244
+ # Function: LoadAndComparePreviousSettings
1245
+ #
1246
+ # Loads <PreviousSettings.nd> and compares the values there with those in the command line. If differences require it,
1247
+ # sets <rebuildData> and/or <rebuildOutput>.
1248
+ #
1249
+ sub LoadAndComparePreviousSettings
1250
+ {
1251
+ my ($self) = @_;
1252
+
1253
+ my $fileIsOkay;
1254
+
1255
+ if (!NaturalDocs::Settings->RebuildData())
1256
+ {
1257
+ my $version;
1258
+
1259
+ if (NaturalDocs::BinaryFile->OpenForReading( NaturalDocs::Project->DataFile('PreviousSettings.nd'),
1260
+ NaturalDocs::Version->FromString('1.4') ))
1261
+ { $fileIsOkay = 1; };
1262
+ };
1263
+
1264
+ if (!$fileIsOkay)
1265
+ {
1266
+ # We need to reparse everything because --documented-only may have changed.
1267
+ # We need to rebuild everything because --tab-length may have changed.
1268
+ NaturalDocs::Project->ReparseEverything();
1269
+ NaturalDocs::Project->RebuildEverything();
1270
+ }
1271
+ else
1272
+ {
1273
+ my $raw;
1274
+
1275
+ # [UInt8: tab expansion]
1276
+ # [UInt8: documented only (0 or 1)]
1277
+ # [UInt8: no auto-group (0 or 1)]
1278
+ # [UInt8: only file titles (0 or 1)]
1279
+ # [AString16: charset]
1280
+
1281
+ my $prevTabLength = NaturalDocs::BinaryFile->GetUInt8();
1282
+ my $prevDocumentedOnly = NaturalDocs::BinaryFile->GetUInt8();
1283
+ my $prevNoAutoGroup = NaturalDocs::BinaryFile->GetUInt8();
1284
+ my $prevOnlyFileTitles = NaturalDocs::BinaryFile->GetUInt8();
1285
+ my $prevCharset = NaturalDocs::BinaryFile->GetAString16();
1286
+
1287
+ if ($prevTabLength != $self->TabLength())
1288
+ {
1289
+ # We need to rebuild all output because this affects all text diagrams.
1290
+ NaturalDocs::Project->RebuildEverything();
1291
+ };
1292
+
1293
+ if ($prevDocumentedOnly == 0)
1294
+ { $prevDocumentedOnly = undef; };
1295
+ if ($prevNoAutoGroup == 0)
1296
+ { $prevNoAutoGroup = undef; };
1297
+ if ($prevOnlyFileTitles == 0)
1298
+ { $prevOnlyFileTitles = undef; };
1299
+
1300
+ if ($prevDocumentedOnly != $self->DocumentedOnly() ||
1301
+ $prevNoAutoGroup != $self->NoAutoGroup() ||
1302
+ $prevOnlyFileTitles != $self->OnlyFileTitles())
1303
+ {
1304
+ NaturalDocs::Project->ReparseEverything();
1305
+ };
1306
+
1307
+ if ($prevCharset ne $charset)
1308
+ { NaturalDocs::Project->RebuildEverything(); };
1309
+
1310
+
1311
+ # [UInt8: number of input directories]
1312
+
1313
+ my $inputDirectoryCount = NaturalDocs::BinaryFile->GetUInt8();
1314
+
1315
+ while ($inputDirectoryCount)
1316
+ {
1317
+ # [AString16: input directory] [AString16: input directory name] ...
1318
+
1319
+ my $inputDirectory = NaturalDocs::BinaryFile->GetAString16();
1320
+ my $inputDirectoryName = NaturalDocs::BinaryFile->GetAString16();
1321
+
1322
+ # Not doing anything with this for now.
1323
+
1324
+ $inputDirectoryCount--;
1325
+ };
1326
+
1327
+
1328
+ # [UInt8: number of output targets]
1329
+
1330
+ my $outputTargetCount = NaturalDocs::BinaryFile->GetUInt8();
1331
+
1332
+ # Keys are the directories, values are the command line options.
1333
+ my %previousOutputDirectories;
1334
+
1335
+ while ($outputTargetCount)
1336
+ {
1337
+ # [AString16: output directory] [AString16: output format command line option] ...
1338
+
1339
+ my $outputDirectory = NaturalDocs::BinaryFile->GetAString16();
1340
+ my $outputCommand = NaturalDocs::BinaryFile->GetAString16();
1341
+
1342
+ $previousOutputDirectories{$outputDirectory} = $outputCommand;
1343
+
1344
+ $outputTargetCount--;
1345
+ };
1346
+
1347
+ # Check if any targets were added to the command line, or if their formats changed. We don't care if targets were
1348
+ # removed.
1349
+ my $buildTargets = $self->BuildTargets();
1350
+
1351
+ foreach my $buildTarget (@$buildTargets)
1352
+ {
1353
+ if (!exists $previousOutputDirectories{$buildTarget->Directory()} ||
1354
+ $buildTarget->Builder()->CommandLineOption() ne $previousOutputDirectories{$buildTarget->Directory()})
1355
+ {
1356
+ NaturalDocs::Project->RebuildEverything();
1357
+ last;
1358
+ };
1359
+ };
1360
+
1361
+ NaturalDocs::BinaryFile->Close();
1362
+ };
1363
+ };
1364
+
1365
+
1366
+ #
1367
+ # Function: SavePreviousSettings
1368
+ #
1369
+ # Saves the settings into <PreviousSettings.nd>.
1370
+ #
1371
+ sub SavePreviousSettings
1372
+ {
1373
+ my ($self) = @_;
1374
+
1375
+ NaturalDocs::BinaryFile->OpenForWriting( NaturalDocs::Project->DataFile('PreviousSettings.nd') );
1376
+
1377
+ # [UInt8: tab length]
1378
+ # [UInt8: documented only (0 or 1)]
1379
+ # [UInt8: no auto-group (0 or 1)]
1380
+ # [UInt8: only file titles (0 or 1)]
1381
+ # [AString16: charset]
1382
+ # [UInt8: number of input directories]
1383
+
1384
+ my $inputDirectories = $self->InputDirectories();
1385
+
1386
+ NaturalDocs::BinaryFile->WriteUInt8($self->TabLength());
1387
+ NaturalDocs::BinaryFile->WriteUInt8($self->DocumentedOnly() ? 1 : 0);
1388
+ NaturalDocs::BinaryFile->WriteUInt8($self->NoAutoGroup() ? 1 : 0);
1389
+ NaturalDocs::BinaryFile->WriteUInt8($self->OnlyFileTitles() ? 1 : 0);
1390
+ NaturalDocs::BinaryFile->WriteAString16($charset);
1391
+ NaturalDocs::BinaryFile->WriteUInt8(scalar @$inputDirectories);
1392
+
1393
+ foreach my $inputDirectory (@$inputDirectories)
1394
+ {
1395
+ my $inputDirectoryName = $self->InputDirectoryNameOf($inputDirectory);
1396
+
1397
+ # [AString16: input directory] [AString16: input directory name] ...
1398
+ NaturalDocs::BinaryFile->WriteAString16($inputDirectory);
1399
+ NaturalDocs::BinaryFile->WriteAString16($inputDirectoryName);
1400
+ };
1401
+
1402
+ # [UInt8: number of output targets]
1403
+
1404
+ my $buildTargets = $self->BuildTargets();
1405
+ NaturalDocs::BinaryFile->WriteUInt8(scalar @$buildTargets);
1406
+
1407
+ foreach my $buildTarget (@$buildTargets)
1408
+ {
1409
+ # [AString16: output directory] [AString16: output format command line option] ...
1410
+ NaturalDocs::BinaryFile->WriteAString16( $buildTarget->Directory() );
1411
+ NaturalDocs::BinaryFile->WriteAString16( $buildTarget->Builder()->CommandLineOption() );
1412
+ };
1413
+
1414
+ NaturalDocs::BinaryFile->Close();
1415
+ };
1416
+
1417
+
1418
+ 1;