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,1475 @@
1
+ ###############################################################################
2
+ #
3
+ # Package: NaturalDocs::Languages
4
+ #
5
+ ###############################################################################
6
+ #
7
+ # A package to manage all the programming languages Natural Docs supports.
8
+ #
9
+ # Usage and Dependencies:
10
+ #
11
+ # - Prior to use, <NaturalDocs::Settings> must be initialized and <Load()> must be called.
12
+ #
13
+ ###############################################################################
14
+
15
+ # This file is part of Natural Docs, which is Copyright (C) 2003-2008 Greg Valure
16
+ # Natural Docs is licensed under the GPL
17
+
18
+ use Text::Wrap();
19
+
20
+ use NaturalDocs::Languages::Prototype;
21
+
22
+ use NaturalDocs::Languages::Base;
23
+ use NaturalDocs::Languages::Simple;
24
+ use NaturalDocs::Languages::Advanced;
25
+
26
+ use NaturalDocs::Languages::Perl;
27
+ use NaturalDocs::Languages::CSharp;
28
+ use NaturalDocs::Languages::ActionScript;
29
+
30
+ use NaturalDocs::Languages::Ada;
31
+ use NaturalDocs::Languages::PLSQL;
32
+ use NaturalDocs::Languages::Pascal;
33
+ use NaturalDocs::Languages::Tcl;
34
+
35
+ use strict;
36
+ use integer;
37
+
38
+ package NaturalDocs::Languages;
39
+
40
+
41
+ ###############################################################################
42
+ # Group: Variables
43
+
44
+
45
+ #
46
+ # handle: FH_LANGUAGES
47
+ #
48
+ # The file handle used for writing to <Languages.txt>.
49
+ #
50
+
51
+
52
+ #
53
+ # hash: languages
54
+ #
55
+ # A hash of all the defined languages. The keys are the all-lowercase language names, and the values are
56
+ # <NaturalDocs::Languages::Base>-derived objects.
57
+ #
58
+ my %languages;
59
+
60
+ #
61
+ # hash: extensions
62
+ #
63
+ # A hash of all the defined languages' extensions. The keys are the all-lowercase extensions, and the values are the
64
+ # all-lowercase names of the languages that defined them.
65
+ #
66
+ my %extensions;
67
+
68
+ #
69
+ # hash: shebangStrings
70
+ #
71
+ # A hash of all the defined languages' strings to search for in the shebang (#!) line. The keys are the all-lowercase strings, and
72
+ # the values are the all-lowercase names of the languages that defined them.
73
+ #
74
+ my %shebangStrings;
75
+
76
+ #
77
+ # hash: shebangFiles
78
+ #
79
+ # A hash of all the defined languages for files where it needs to be found via shebang strings. The keys are the file names,
80
+ # and the values are language names, or undef if the file isn't supported. These values should be filled in the first time
81
+ # each file is parsed for a shebang string so that it doesn't have to be done multiple times.
82
+ #
83
+ my %shebangFiles;
84
+
85
+ #
86
+ # array: mainLanguageNames
87
+ #
88
+ # An array of the language names that are defined in the main <Languages.txt>.
89
+ #
90
+ my @mainLanguageNames;
91
+
92
+
93
+
94
+ ###############################################################################
95
+ # Group: Files
96
+
97
+
98
+ #
99
+ # File: Languages.txt
100
+ #
101
+ # The configuration file that defines or overrides the language definitions for Natural Docs. One version sits in Natural Docs'
102
+ # configuration directory, and another can be in a project directory to add to or override them.
103
+ #
104
+ # > # [comments]
105
+ #
106
+ # Everything after a # symbol is ignored. However, for this particular file, comments can only appear on their own lines.
107
+ # They cannot appear after content on the same line.
108
+ #
109
+ # > Format: [version]
110
+ #
111
+ # Specifies the file format version of the file.
112
+ #
113
+ #
114
+ # Sections:
115
+ #
116
+ # > Ignore[d] Extension[s]: [extension] [extension] ...
117
+ #
118
+ # Causes the listed file extensions to be ignored, even if they were previously defined to be part of a language. The list is
119
+ # space-separated. ex. "Ignore Extensions: cvs txt"
120
+ #
121
+ #
122
+ # > Language: [name]
123
+ #
124
+ # Creates a new language. Everything underneath applies to this language until the next one. Names can use any
125
+ # characters.
126
+ #
127
+ # The languages "Text File" and "Shebang Script" have special meanings. Text files are considered all comment and don't
128
+ # have comment symbols. Shebang scripts have their language determined by the shebang string and automatically
129
+ # include files with no extension in addition to the extensions defined.
130
+ #
131
+ # If "Text File" doesn't define ignored prefixes, a package separator, or enum value behavior, those settings will be copied
132
+ # from the language with the most files in the source tree.
133
+ #
134
+ #
135
+ # > Alter Language: [name]
136
+ #
137
+ # Alters an existing language. Everything underneath it overrides the previous settings until the next one. Note that if a
138
+ # property has an [Add/Replace] form and that property has already been defined, you have to specify whether you're adding
139
+ # to or replacing the defined list.
140
+ #
141
+ #
142
+ # Language Properties:
143
+ #
144
+ # > Extension[s]: [extension] [extension] ...
145
+ # > [Add/Replace] Extension[s]: ...
146
+ #
147
+ # Defines file extensions for the language's source files. The list is space-separated. ex. "Extensions: c cpp". You can use
148
+ # extensions that were previously used by another language to redefine them.
149
+ #
150
+ #
151
+ # > Shebang String[s]: [string] [string] ...
152
+ # > [Add/Replace] Shebang String[s]: ...
153
+ #
154
+ # Defines a list of strings that can appear in the shebang (#!) line to designate that it's part of this language. They can
155
+ # appear anywhere in the line, so "php" will work for "#!/user/bin/php4". You can use strings that were previously used by
156
+ # another language to redefine them.
157
+ #
158
+ #
159
+ # > Ignore[d] Prefix[es] in Index: [prefix] [prefix] ...
160
+ # > Ignore[d] [Topic Type] Prefix[es] in Index: [prefix] [prefix] ...
161
+ # > [Add/Replace] Ignore[d] Prefix[es] in Index: ...
162
+ # > [Add/Replace] Ignore[d] [Topic Type] Prefix[es] in Index: ...
163
+ #
164
+ # Specifies prefixes that should be ignored when sorting symbols for an index. Can be specified in general or for a specific
165
+ # <TopicType>. The prefixes will still appear, the symbols will just be sorted as if they're not there. For example, specifying
166
+ # "ADO_" for functions will mean that "ADO_DoSomething" will appear under D instead of A.
167
+ #
168
+ #
169
+ # Basic Language Support Properties:
170
+ #
171
+ # These attributes are only available for languages with basic language support.
172
+ #
173
+ #
174
+ # > Line Comment[s]: [symbol] [symbol] ...
175
+ #
176
+ # Defines a space-separated list of symbols that are used for line comments, if any. ex. "Line Comment: //".
177
+ #
178
+ #
179
+ # > Block Comment[s]: [opening symbol] [closing symbol] [opening symbol] [closing symbol] ...
180
+ #
181
+ # Defines a space-separated list of symbol pairs that are used for block comments, if any. ex. "Block Comment: /* */".
182
+ #
183
+ #
184
+ # > Package Separator: [symbol]
185
+ #
186
+ # Defines the default package separator symbol, such as . or ::. This is for presentation only and will not affect how
187
+ # Natural Docs links are parsed. The default is a dot.
188
+ #
189
+ #
190
+ # > [Topic Type] Prototype Ender[s]: [symbol] [symbol] ...
191
+ #
192
+ # When defined, Natural Docs will attempt to collect prototypes from the code following the specified <TopicType>. It grabs
193
+ # code until the first ender symbol or the next Natural Docs comment, and if it contains the topic name, it serves as its
194
+ # prototype. Use \n to specify a line break. ex. "Function Prototype Enders: { ;", "Variable Prototype Enders: = ;".
195
+ #
196
+ #
197
+ # > Line Extender: [symbol]
198
+ #
199
+ # Defines the symbol that allows a prototype to span multiple lines if normally a line break would end it.
200
+ #
201
+ #
202
+ # > Enum Values: [global|under type|under parent]
203
+ #
204
+ # Defines how enum values are referenced. The default is global.
205
+ #
206
+ # global - Values are always global, referenced as 'value'.
207
+ # under type - Values are under the enum type, referenced as 'package.enum.value'.
208
+ # under parent - Values are under the enum's parent, referenced as 'package.value'.
209
+ #
210
+ #
211
+ # > Perl Package: [perl package]
212
+ #
213
+ # Specifies the Perl package used to fine-tune the language behavior in ways too complex to do in this file.
214
+ #
215
+ #
216
+ # Full Language Support Properties:
217
+ #
218
+ # These attributes are only available for languages with full language support.
219
+ #
220
+ #
221
+ # > Full Language Support: [perl package]
222
+ #
223
+ # Specifies the Perl package that has the parsing routines necessary for full language support.
224
+ #
225
+ #
226
+ # Revisions:
227
+ #
228
+ # 1.32:
229
+ #
230
+ # - Package Separator is now a basic language support only property.
231
+ # - Added Enum Values setting.
232
+ #
233
+ # 1.3:
234
+ #
235
+ # - The file was introduced.
236
+
237
+
238
+ ###############################################################################
239
+ # Group: File Functions
240
+
241
+
242
+ #
243
+ # Function: Load
244
+ #
245
+ # Loads both the master and the project version of <Languages.txt>.
246
+ #
247
+ sub Load
248
+ {
249
+ my $self = shift;
250
+
251
+ # Hashrefs where the keys are all-lowercase extensions/shebang strings, and the values are arrayrefs of the languages
252
+ # that defined them, earliest first, all lowercase.
253
+ my %tempExtensions;
254
+ my %tempShebangStrings;
255
+
256
+ $self->LoadFile(1, \%tempExtensions, \%tempShebangStrings); # Main
257
+
258
+ if (!exists $languages{'shebang script'})
259
+ { NaturalDocs::ConfigFile->AddError('You must define "Shebang Script" in the main languages file.'); };
260
+ if (!exists $languages{'text file'})
261
+ { NaturalDocs::ConfigFile->AddError('You must define "Text File" in the main languages file.'); };
262
+
263
+ my $errorCount = NaturalDocs::ConfigFile->ErrorCount();
264
+
265
+ if ($errorCount)
266
+ {
267
+ NaturalDocs::ConfigFile->PrintErrorsAndAnnotateFile();
268
+ NaturalDocs::Error->SoftDeath('There ' . ($errorCount == 1 ? 'is an error' : 'are ' . $errorCount . ' errors')
269
+ . ' in ' . NaturalDocs::Project->MainConfigFile('Languages.txt'));
270
+ }
271
+
272
+
273
+ $self->LoadFile(0, \%tempExtensions, \%tempShebangStrings); # User
274
+
275
+ $errorCount = NaturalDocs::ConfigFile->ErrorCount();
276
+
277
+ if ($errorCount)
278
+ {
279
+ NaturalDocs::ConfigFile->PrintErrorsAndAnnotateFile();
280
+ NaturalDocs::Error->SoftDeath('There ' . ($errorCount == 1 ? 'is an error' : 'are ' . $errorCount . ' errors')
281
+ . ' in ' . NaturalDocs::Project->UserConfigFile('Languages.txt'));
282
+ };
283
+
284
+
285
+ # Convert the temp hashes into the real ones.
286
+
287
+ while (my ($extension, $languages) = each %tempExtensions)
288
+ {
289
+ $extensions{$extension} = $languages->[-1];
290
+ };
291
+ while (my ($shebangString, $languages) = each %tempShebangStrings)
292
+ {
293
+ $shebangStrings{$shebangString} = $languages->[-1];
294
+ };
295
+ };
296
+
297
+
298
+ #
299
+ # Function: LoadFile
300
+ #
301
+ # Loads a particular version of <Languages.txt>.
302
+ #
303
+ # Parameters:
304
+ #
305
+ # isMain - Whether the file is the main file or not.
306
+ # tempExtensions - A hashref where the keys are all-lowercase extensions, and the values are arrayrefs of the all-lowercase
307
+ # names of the languages that defined them, earliest first. It will be changed by this function.
308
+ # tempShebangStrings - A hashref where the keys are all-lowercase shebang strings, and the values are arrayrefs of the
309
+ # all-lowercase names of the languages that defined them, earliest first. It will be changed by this
310
+ # function.
311
+ #
312
+ sub LoadFile #(isMain, tempExtensions, tempShebangStrings)
313
+ {
314
+ my ($self, $isMain, $tempExtensions, $tempShebangStrings) = @_;
315
+
316
+ my ($file, $status);
317
+
318
+ if ($isMain)
319
+ {
320
+ $file = NaturalDocs::Project->MainConfigFile('Languages.txt');
321
+ $status = NaturalDocs::Project->MainConfigFileStatus('Languages.txt');
322
+ }
323
+ else
324
+ {
325
+ $file = NaturalDocs::Project->UserConfigFile('Languages.txt');
326
+ $status = NaturalDocs::Project->UserConfigFileStatus('Languages.txt');
327
+ };
328
+
329
+
330
+ my $version;
331
+
332
+ # An array of properties for the current language. Each entry is the three consecutive values ( lineNumber, keyword, value ).
333
+ my @properties;
334
+
335
+ if ($version = NaturalDocs::ConfigFile->Open($file))
336
+ {
337
+ # The format hasn't changed significantly since the file was introduced.
338
+
339
+ if ($status == ::FILE_CHANGED())
340
+ {
341
+ NaturalDocs::Project->ReparseEverything();
342
+ NaturalDocs::SymbolTable->RebuildAllIndexes(); # Because the ignored prefixes could change.
343
+ };
344
+
345
+ my ($keyword, $value, $comment);
346
+
347
+ while (($keyword, $value, $comment) = NaturalDocs::ConfigFile->GetLine())
348
+ {
349
+ $value .= $comment;
350
+ $value =~ s/^ //;
351
+
352
+ # Process previous properties.
353
+ if (($keyword eq 'language' || $keyword eq 'alter language') && scalar @properties)
354
+ {
355
+ if ($isMain && $properties[1] eq 'language')
356
+ { push @mainLanguageNames, $properties[2]; };
357
+
358
+ $self->ProcessProperties(\@properties, $version, $tempExtensions, $tempShebangStrings);
359
+ @properties = ( );
360
+ };
361
+
362
+ if ($keyword =~ /^ignored? extensions?$/)
363
+ {
364
+ $value =~ tr/.*//d;
365
+ my @extensions = split(/ /, lc($value));
366
+
367
+ foreach my $extension (@extensions)
368
+ { delete $tempExtensions->{$extension}; };
369
+ }
370
+ else
371
+ {
372
+ push @properties, NaturalDocs::ConfigFile->LineNumber(), $keyword, $value;
373
+ };
374
+ };
375
+
376
+ if (scalar @properties)
377
+ {
378
+ if ($isMain && $properties[1] eq 'language')
379
+ { push @mainLanguageNames, $properties[2]; };
380
+
381
+ $self->ProcessProperties(\@properties, $version, $tempExtensions, $tempShebangStrings);
382
+ };
383
+ }
384
+
385
+ else # couldn't open file
386
+ {
387
+ if ($isMain)
388
+ { die "Couldn't open languages file " . $file . "\n"; };
389
+ };
390
+ };
391
+
392
+
393
+ #
394
+ # Function: ProcessProperties
395
+ #
396
+ # Processes an array of language properties from <Languages.txt>.
397
+ #
398
+ # Parameters:
399
+ #
400
+ # properties - An arrayref of properties where each entry is the three consecutive values ( lineNumber, keyword, value ).
401
+ # It must start with the Language or Alter Language property.
402
+ # version - The <VersionInt> of the file.
403
+ # tempExtensions - A hashref where the keys are all-lowercase extensions, and the values are arrayrefs of the all-lowercase
404
+ # names of the languages that defined them, earliest first. It will be changed by this function.
405
+ # tempShebangStrings - A hashref where the keys are all-lowercase shebang strings, and the values are arrayrefs of the
406
+ # all-lowercase names of the languages that defined them, earliest first. It will be changed by this
407
+ # function.
408
+ #
409
+ sub ProcessProperties #(properties, version, tempExtensions, tempShebangStrings)
410
+ {
411
+ my ($self, $properties, $version, $tempExtensions, $tempShebangStrings) = @_;
412
+
413
+
414
+ # First validate the name and check whether the language has full support.
415
+
416
+ my $language;
417
+ my $fullLanguageSupport;
418
+ my ($lineNumber, $languageKeyword, $languageName) = @$properties[0..2];
419
+ my $lcLanguageName = lc($languageName);
420
+ my ($keyword, $value);
421
+
422
+ if ($languageKeyword eq 'alter language')
423
+ {
424
+ $language = $languages{$lcLanguageName};
425
+
426
+ if (!defined $language)
427
+ {
428
+ NaturalDocs::ConfigFile->AddError('The language ' . $languageName . ' is not defined.', $lineNumber);
429
+ return;
430
+ }
431
+ else
432
+ {
433
+ $fullLanguageSupport = (!$language->isa('NaturalDocs::Languages::Simple'));
434
+ };
435
+ }
436
+
437
+ elsif ($languageKeyword eq 'language')
438
+ {
439
+ if (exists $languages{$lcLanguageName})
440
+ {
441
+ NaturalDocs::ConfigFile->AddError('The language ' . $value . ' is already defined. Use "Alter Language" if you want '
442
+ . 'to override its settings.', $lineNumber);
443
+ return;
444
+ };
445
+
446
+ # Case is important with these two.
447
+ if ($lcLanguageName eq 'shebang script')
448
+ { $languageName = 'Shebang Script'; }
449
+ elsif ($lcLanguageName eq 'text file')
450
+ { $languageName = 'Text File'; };
451
+
452
+
453
+ # Go through the properties looking for whether the language has basic or full support and which package to use to create
454
+ # it.
455
+
456
+ for (my $i = 3; $i < scalar @$properties; $i += 3)
457
+ {
458
+ ($lineNumber, $keyword, $value) = @$properties[$i..$i+2];
459
+
460
+ if ($keyword eq 'full language support')
461
+ {
462
+ $fullLanguageSupport = 1;
463
+
464
+ eval
465
+ {
466
+ $language = $value->New($languageName);
467
+ };
468
+ if ($::EVAL_ERROR)
469
+ {
470
+ NaturalDocs::ConfigFile->AddError('Could not create ' . $value . ' object.', $lineNumber);
471
+ return;
472
+ };
473
+
474
+ last;
475
+ }
476
+
477
+ elsif ($keyword eq 'perl package')
478
+ {
479
+ eval
480
+ {
481
+ $language = $value->New($languageName);
482
+ };
483
+ if ($::EVAL_ERROR)
484
+ {
485
+ NaturalDocs::ConfigFile->AddError('Could not create ' . $value . ' object.', $lineNumber);
486
+ return;
487
+ };
488
+ };
489
+ };
490
+
491
+ # If $language was not created by now, it's a generic basic support language.
492
+ if (!defined $language)
493
+ { $language = NaturalDocs::Languages::Simple->New($languageName); };
494
+
495
+ $languages{$lcLanguageName} = $language;
496
+ }
497
+
498
+ else # not language or alter language
499
+ {
500
+ NaturalDocs::ConfigFile->AddError('You must start this line with "Language", "Alter Language", or "Ignore Extensions".',
501
+ $lineNumber);
502
+ return;
503
+ };
504
+
505
+
506
+ # Decode the properties.
507
+
508
+ for (my $i = 3; $i < scalar @$properties; $i += 3)
509
+ {
510
+ ($lineNumber, $keyword, $value) = @$properties[$i..$i+2];
511
+
512
+ if ($keyword =~ /^(?:(add|replace) )?extensions?$/)
513
+ {
514
+ my $command = $1;
515
+
516
+
517
+ # Remove old extensions.
518
+
519
+ if (defined $language->Extensions() && $command eq 'replace')
520
+ {
521
+ foreach my $extension (@{$language->Extensions()})
522
+ {
523
+ if (exists $tempExtensions->{$extension})
524
+ {
525
+ my $languages = $tempExtensions->{$extension};
526
+ my $i = 0;
527
+
528
+ while ($i < scalar @$languages)
529
+ {
530
+ if ($languages->[$i] eq $lcLanguageName)
531
+ { splice(@$languages, $i, 1); }
532
+ else
533
+ { $i++; };
534
+ };
535
+
536
+ if (!scalar @$languages)
537
+ { delete $tempExtensions->{$extension}; };
538
+ };
539
+ };
540
+ };
541
+
542
+
543
+ # Add new extensions.
544
+
545
+ # Ignore stars and dots so people could use .ext or *.ext.
546
+ $value =~ s/\*\.|\.//g;
547
+
548
+ my @extensions = split(/ /, lc($value));
549
+
550
+ foreach my $extension (@extensions)
551
+ {
552
+ if (!exists $tempExtensions->{$extension})
553
+ { $tempExtensions->{$extension} = [ ]; };
554
+
555
+ push @{$tempExtensions->{$extension}}, $lcLanguageName;
556
+ };
557
+
558
+
559
+ # Set the extensions for the language object.
560
+
561
+ if (defined $language->Extensions())
562
+ {
563
+ if ($command eq 'add')
564
+ { push @extensions, @{$language->Extensions()}; }
565
+ elsif (!$command)
566
+ {
567
+ NaturalDocs::ConfigFile->AddError('You need to specify whether you are adding to or replacing the list of extensions.',
568
+ $lineNumber);
569
+ };
570
+ };
571
+
572
+ $language->SetExtensions(\@extensions);
573
+ }
574
+
575
+ elsif ($keyword =~ /^(?:(add|replace) )?shebang strings?$/)
576
+ {
577
+ my $command = $1;
578
+
579
+
580
+ # Remove old strings.
581
+
582
+ if (defined $language->ShebangStrings() && $command eq 'replace')
583
+ {
584
+ foreach my $shebangString (@{$language->ShebangStrings()})
585
+ {
586
+ if (exists $tempShebangStrings->{$shebangString})
587
+ {
588
+ my $languages = $tempShebangStrings->{$shebangString};
589
+ my $i = 0;
590
+
591
+ while ($i < scalar @$languages)
592
+ {
593
+ if ($languages->[$i] eq $lcLanguageName)
594
+ { splice(@$languages, $i, 1); }
595
+ else
596
+ { $i++; };
597
+ };
598
+
599
+ if (!scalar @$languages)
600
+ { delete $tempShebangStrings->{$shebangString}; };
601
+ };
602
+ };
603
+ };
604
+
605
+
606
+ # Add new strings.
607
+
608
+ my @shebangStrings = split(/ /, lc($value));
609
+
610
+ foreach my $shebangString (@shebangStrings)
611
+ {
612
+ if (!exists $tempShebangStrings->{$shebangString})
613
+ { $tempShebangStrings->{$shebangString} = [ ]; };
614
+
615
+ push @{$tempShebangStrings->{$shebangString}}, $lcLanguageName;
616
+ };
617
+
618
+
619
+ # Set the strings for the language object.
620
+
621
+ if (defined $language->ShebangStrings())
622
+ {
623
+ if ($command eq 'add')
624
+ { push @shebangStrings, @{$language->ShebangStrings()}; }
625
+ elsif (!$command)
626
+ {
627
+ NaturalDocs::ConfigFile->AddError('You need to specify whether you are adding to or replacing the list of shebang '
628
+ . 'strings.', $lineNumber);
629
+ };
630
+ };
631
+
632
+ $language->SetShebangStrings(\@shebangStrings);
633
+ }
634
+
635
+ elsif ($keyword eq 'package separator')
636
+ {
637
+ if ($fullLanguageSupport)
638
+ {
639
+ # Prior to 1.32, package separator was used with full language support too. Accept it without complaining, even though
640
+ # we ignore it.
641
+ if ($version >= NaturalDocs::Version->FromString('1.32'))
642
+ {
643
+ NaturalDocs::ConfigFile->AddError('You cannot define this property when using full language support.', $lineNumber);
644
+ };
645
+ }
646
+ else
647
+ { $language->SetPackageSeparator($value); };
648
+ }
649
+
650
+ elsif ($keyword =~ /^(?:(add|replace) )?ignored? (?:(.+) )?prefix(?:es)? in index$/)
651
+ {
652
+ my ($command, $topicName) = ($1, $2);
653
+ my $topicType;
654
+
655
+ if ($topicName)
656
+ {
657
+ if (!( ($topicType, undef) = NaturalDocs::Topics->NameInfo($topicName) ))
658
+ {
659
+ NaturalDocs::ConfigFile->AddError($topicName . ' is not a defined topic type.', $lineNumber);
660
+ };
661
+ }
662
+ else
663
+ { $topicType = ::TOPIC_GENERAL(); };
664
+
665
+ if ($topicType)
666
+ {
667
+ my @prefixes;
668
+
669
+ if (defined $language->IgnoredPrefixesFor($topicType))
670
+ {
671
+ if ($command eq 'add')
672
+ { @prefixes = @{$language->IgnoredPrefixesFor($topicType)}; }
673
+ elsif (!$command)
674
+ {
675
+ NaturalDocs::ConfigFile->AddError('You need to specify whether you are adding to or replacing the list of '
676
+ . 'ignored prefixes.', $lineNumber);
677
+ };
678
+ };
679
+
680
+ push @prefixes, split(/ /, $value);
681
+ $language->SetIgnoredPrefixesFor($topicType, \@prefixes);
682
+ };
683
+ }
684
+
685
+ elsif ($keyword eq 'full language support' || $keyword eq 'perl package')
686
+ {
687
+ if ($languageKeyword eq 'alter language')
688
+ {
689
+ NaturalDocs::ConfigFile->AddError('You cannot use ' . $keyword . ' with Alter Language.', $lineNumber);
690
+ };
691
+ # else ignore it.
692
+ }
693
+
694
+ elsif ($keyword =~ /^line comments?$/)
695
+ {
696
+ if ($fullLanguageSupport)
697
+ {
698
+ NaturalDocs::ConfigFile->AddError('You cannot define this property when using full language support.', $lineNumber);
699
+ }
700
+ else
701
+ {
702
+ my @symbols = split(/ /, $value);
703
+ $language->SetLineCommentSymbols(\@symbols);
704
+ };
705
+ }
706
+
707
+ elsif ($keyword =~ /^block comments?$/)
708
+ {
709
+ if ($fullLanguageSupport)
710
+ {
711
+ NaturalDocs::ConfigFile->AddError('You cannot define this property when using full language support.', $lineNumber);
712
+ }
713
+ else
714
+ {
715
+ my @symbols = split(/ /, $value);
716
+
717
+ if ((scalar @symbols) % 2 == 0)
718
+ { $language->SetBlockCommentSymbols(\@symbols); }
719
+ else
720
+ { NaturalDocs::ConfigFile->AddError('Block comment symbols must appear in pairs.', $lineNumber); };
721
+ };
722
+ }
723
+
724
+ elsif ($keyword =~ /^(?:(.+) )?prototype enders?$/)
725
+ {
726
+ if ($fullLanguageSupport)
727
+ {
728
+ NaturalDocs::ConfigFile->AddError('You cannot define this property when using full language support.', $lineNumber);
729
+ }
730
+ else
731
+ {
732
+ my $topicName = $1;
733
+ my $topicType;
734
+
735
+ if ($topicName)
736
+ {
737
+ if (!( ($topicType, undef) = NaturalDocs::Topics->NameInfo($topicName) ))
738
+ {
739
+ NaturalDocs::ConfigFile->AddError($topicName . ' is not a defined topic type.', $lineNumber);
740
+ };
741
+ }
742
+ else
743
+ { $topicType = ::TOPIC_GENERAL(); };
744
+
745
+ if ($topicType)
746
+ {
747
+ $value =~ s/\\n/\n/g;
748
+ my @symbols = split(/ /, $value);
749
+ $language->SetPrototypeEndersFor($topicType, \@symbols);
750
+ };
751
+ };
752
+ }
753
+
754
+ elsif ($keyword eq 'line extender')
755
+ {
756
+ if ($fullLanguageSupport)
757
+ {
758
+ NaturalDocs::ConfigFile->AddError('You cannot define this property when using full language support.', $lineNumber);
759
+ }
760
+ else
761
+ {
762
+ $language->SetLineExtender($value);
763
+ };
764
+ }
765
+
766
+ elsif ($keyword eq 'enum values')
767
+ {
768
+ if ($fullLanguageSupport)
769
+ {
770
+ NaturalDocs::ConfigFile->AddError('You cannot define this property when using full language support.', $lineNumber);
771
+ }
772
+ else
773
+ {
774
+ $value = lc($value);
775
+ my $constant;
776
+
777
+ if ($value eq 'global')
778
+ { $constant = ::ENUM_GLOBAL(); }
779
+ elsif ($value eq 'under type')
780
+ { $constant = ::ENUM_UNDER_TYPE(); }
781
+ elsif ($value eq 'under parent')
782
+ { $constant = ::ENUM_UNDER_PARENT(); };
783
+
784
+ if (defined $constant)
785
+ { $language->SetEnumValues($constant); }
786
+ else
787
+ {
788
+ NaturalDocs::ConfigFile->AddError('Enum Values must be "Global", "Under Type", or "Under Parent".', $lineNumber);
789
+ };
790
+ };
791
+ }
792
+
793
+ else
794
+ {
795
+ NaturalDocs::ConfigFile->AddError($keyword . ' is not a valid keyword.', $lineNumber);
796
+ };
797
+ };
798
+ };
799
+
800
+
801
+ #
802
+ # Function: Save
803
+ #
804
+ # Saves the main and user versions of <Languages.txt>.
805
+ #
806
+ sub Save
807
+ {
808
+ my $self = shift;
809
+
810
+ $self->SaveFile(1); # Main
811
+ $self->SaveFile(0); # User
812
+ };
813
+
814
+
815
+ #
816
+ # Function: SaveFile
817
+ #
818
+ # Saves a particular version of <Topics.txt>.
819
+ #
820
+ # Parameters:
821
+ #
822
+ # isMain - Whether the file is the main file or not.
823
+ #
824
+ sub SaveFile #(isMain)
825
+ {
826
+ my ($self, $isMain) = @_;
827
+
828
+ my $file;
829
+
830
+ if ($isMain)
831
+ {
832
+ if (NaturalDocs::Project->MainConfigFileStatus('Languages.txt') == ::FILE_SAME())
833
+ { return; };
834
+ $file = NaturalDocs::Project->MainConfigFile('Languages.txt');
835
+ }
836
+ else
837
+ {
838
+ # Have to check the main too because this file lists the languages defined there.
839
+ if (NaturalDocs::Project->UserConfigFileStatus('Languages.txt') == ::FILE_SAME() &&
840
+ NaturalDocs::Project->MainConfigFileStatus('Languages.txt') == ::FILE_SAME())
841
+ { return; };
842
+ $file = NaturalDocs::Project->UserConfigFile('Languages.txt');
843
+ };
844
+
845
+
846
+ # Array of segments, with each being groups of three consecutive entries. The first is the keyword ('language' or
847
+ # 'alter language'), the second is the value, and the third is a hashref of all the properties.
848
+ # - For properties that can accept a topic type, the property values are hashrefs mapping topic types to the values.
849
+ # - For properties that can accept 'add' or 'replace', there is an additional property ending in 'command' that stores it.
850
+ # - For properties that can accept both, the 'command' thing is applied to the topic types rather than the properties.
851
+ my @segments;
852
+
853
+ my @ignoredExtensions;
854
+
855
+ my $currentProperties;
856
+ my $version;
857
+
858
+ if ($version = NaturalDocs::ConfigFile->Open($file))
859
+ {
860
+ # We can assume the file is valid.
861
+
862
+ while (my ($keyword, $value, $comment) = NaturalDocs::ConfigFile->GetLine())
863
+ {
864
+ $value .= $comment;
865
+ $value =~ s/^ //;
866
+
867
+ if ($keyword eq 'language')
868
+ {
869
+ $currentProperties = { };
870
+
871
+ # Case is important with these two.
872
+ if (lc($value) eq 'shebang script')
873
+ { $value = 'Shebang Script'; }
874
+ elsif (lc($value) eq 'text file')
875
+ { $value = 'Text File'; };
876
+
877
+ push @segments, 'language', $value, $currentProperties;
878
+ }
879
+
880
+ elsif ($keyword eq 'alter language')
881
+ {
882
+ $currentProperties = { };
883
+ push @segments, 'alter language', $languages{lc($value)}->Name(), $currentProperties;
884
+ }
885
+
886
+ elsif ($keyword =~ /^ignored? extensions?$/)
887
+ {
888
+ $value =~ tr/*.//d;
889
+ push @ignoredExtensions, split(/ /, $value);
890
+ }
891
+
892
+ elsif ($keyword eq 'package separator' || $keyword eq 'full language support' || $keyword eq 'perl package' ||
893
+ $keyword eq 'line extender' || $keyword eq 'enum values')
894
+ {
895
+ $currentProperties->{$keyword} = $value;
896
+ }
897
+
898
+ elsif ($keyword =~ /^line comments?$/)
899
+ {
900
+ $currentProperties->{'line comments'} = $value;
901
+ }
902
+ elsif ($keyword =~ /^block comments?$/)
903
+ {
904
+ $currentProperties->{'block comments'} = $value;
905
+ }
906
+
907
+ elsif ($keyword =~ /^(?:(add|replace) )?extensions?$/)
908
+ {
909
+ my $command = $1;
910
+
911
+ if ($command eq 'add' && exists $currentProperties->{'extensions'})
912
+ { $currentProperties->{'extensions'} .= ' ' . $value; }
913
+ else
914
+ {
915
+ $currentProperties->{'extensions'} = $value;
916
+ $currentProperties->{'extensions command'} = $command;
917
+ };
918
+ }
919
+
920
+ elsif ($keyword =~ /^(?:(add|replace) )?shebang strings?$/)
921
+ {
922
+ my $command = $1;
923
+
924
+ if ($command eq 'add' && exists $currentProperties->{'shebang strings'})
925
+ { $currentProperties->{'shebang strings'} .= ' ' . $value; }
926
+ else
927
+ {
928
+ $currentProperties->{'shebang strings'} = $value;
929
+ $currentProperties->{'shebang strings command'} = $command;
930
+ };
931
+ }
932
+
933
+ elsif ($keyword =~ /^(?:(.+) )?prototype enders?$/)
934
+ {
935
+ my $topicName = $1;
936
+ my $topicType;
937
+
938
+ if ($topicName)
939
+ { ($topicType, undef) = NaturalDocs::Topics->NameInfo($topicName); }
940
+ else
941
+ { $topicType = ::TOPIC_GENERAL(); };
942
+
943
+ my $currentTypeProperties = $currentProperties->{'prototype enders'};
944
+
945
+ if (!defined $currentTypeProperties)
946
+ {
947
+ $currentTypeProperties = { };
948
+ $currentProperties->{'prototype enders'} = $currentTypeProperties;
949
+ };
950
+
951
+ $currentTypeProperties->{$topicType} = $value;
952
+ }
953
+
954
+ elsif ($keyword =~ /^(?:(add|replace) )?ignored? (?:(.+) )?prefix(?:es)? in index$/)
955
+ {
956
+ my ($command, $topicName) = ($1, $2);
957
+ my $topicType;
958
+
959
+ if ($topicName)
960
+ { ($topicType, undef) = NaturalDocs::Topics->NameInfo($topicName); }
961
+ else
962
+ { $topicType = ::TOPIC_GENERAL(); };
963
+
964
+ my $currentTypeProperties = $currentProperties->{'ignored prefixes in index'};
965
+
966
+ if (!defined $currentTypeProperties)
967
+ {
968
+ $currentTypeProperties = { };
969
+ $currentProperties->{'ignored prefixes in index'} = $currentTypeProperties;
970
+ };
971
+
972
+ if ($command eq 'add' && exists $currentTypeProperties->{$topicType})
973
+ { $currentTypeProperties->{$topicType} .= ' ' . $value; }
974
+ else
975
+ {
976
+ $currentTypeProperties->{$topicType} = $value;
977
+ $currentTypeProperties->{$topicType . ' command'} = $command;
978
+ };
979
+ };
980
+ };
981
+
982
+ NaturalDocs::ConfigFile->Close();
983
+ };
984
+
985
+
986
+ if (!open(FH_LANGUAGES, '>' . $file))
987
+ {
988
+ # The main file may be on a shared volume or some other place the user doesn't have write access to. Since this is only to
989
+ # reformat the file, we can ignore the failure.
990
+ if ($isMain)
991
+ { return; }
992
+ else
993
+ { die "Couldn't save " . $file; };
994
+ };
995
+
996
+ print FH_LANGUAGES 'Format: ' . NaturalDocs::Settings->TextAppVersion() . "\n\n";
997
+
998
+ # Remember the 80 character limit.
999
+
1000
+ if ($isMain)
1001
+ {
1002
+ print FH_LANGUAGES
1003
+ "# This is the main Natural Docs languages file. If you change anything here,\n"
1004
+ . "# it will apply to EVERY PROJECT you use Natural Docs on. If you'd like to\n"
1005
+ . "# change something for just one project, edit the Languages.txt in its project\n"
1006
+ . "# directory instead.\n";
1007
+ }
1008
+ else
1009
+ {
1010
+ print FH_LANGUAGES
1011
+ "# This is the Natural Docs languages file for this project. If you change\n"
1012
+ . "# anything here, it will apply to THIS PROJECT ONLY. If you'd like to change\n"
1013
+ . "# something for all your projects, edit the Languages.txt in Natural Docs'\n"
1014
+ . "# Config directory instead.\n\n\n";
1015
+
1016
+ if (scalar @ignoredExtensions == 1)
1017
+ {
1018
+ print FH_LANGUAGES
1019
+ 'Ignore Extension: ' . $ignoredExtensions[0] . "\n";
1020
+ }
1021
+ elsif (scalar @ignoredExtensions)
1022
+ {
1023
+ print FH_LANGUAGES
1024
+ 'Ignore Extensions: ' . join(' ', @ignoredExtensions) . "\n";
1025
+ }
1026
+ else
1027
+ {
1028
+ print FH_LANGUAGES
1029
+ "# You can prevent certain file extensions from being scanned like this:\n"
1030
+ . "# Ignore Extensions: [extension] [extension] ...\n"
1031
+ };
1032
+ };
1033
+
1034
+ print FH_LANGUAGES
1035
+ "\n\n"
1036
+ . "#-------------------------------------------------------------------------------\n"
1037
+ . "# SYNTAX:\n"
1038
+ . "#\n"
1039
+ . "# Unlike other Natural Docs configuration files, in this file all comments\n"
1040
+ . "# MUST be alone on a line. Some languages deal with the # character, so you\n"
1041
+ . "# cannot put comments on the same line as content.\n"
1042
+ . "#\n"
1043
+ . "# Also, all lists are separated with spaces, not commas, again because some\n"
1044
+ . "# languages may need to use them.\n"
1045
+ . "#\n";
1046
+
1047
+ if ($isMain)
1048
+ {
1049
+ print FH_LANGUAGES
1050
+ "# Language: [name]\n"
1051
+ . "# Defines a new language. Its name can use any characters.\n"
1052
+ . "#\n";
1053
+ }
1054
+ else
1055
+ {
1056
+ print FH_LANGUAGES
1057
+ "# Language: [name]\n"
1058
+ . "# Alter Language: [name]\n"
1059
+ . "# Defines a new language or alters an existing one. Its name can use any\n"
1060
+ . "# characters. If any of the properties below have an add/replace form, you\n"
1061
+ . "# must use that when using Alter Language.\n"
1062
+ . "#\n";
1063
+ };
1064
+
1065
+ print FH_LANGUAGES
1066
+ "# The language Shebang Script is special. It's entry is only used for\n"
1067
+ . "# extensions, and files with those extensions have their shebang (#!) lines\n"
1068
+ . "# read to determine the real language of the file. Extensionless files are\n"
1069
+ . "# always treated this way.\n"
1070
+ . "#\n"
1071
+ . "# The language Text File is also special. It's treated as one big comment\n"
1072
+ . "# so you can put Natural Docs content in them without special symbols. Also,\n"
1073
+ . "# if you don't specify a package separator, ignored prefixes, or enum value\n"
1074
+ . "# behavior, it will copy those settings from the language that is used most\n"
1075
+ . "# in the source tree.\n"
1076
+ . "#\n"
1077
+ . "# Extensions: [extension] [extension] ...\n";
1078
+
1079
+ if ($isMain)
1080
+ {
1081
+ print FH_LANGUAGES
1082
+ "# Defines the file extensions of the language's source files. You can use *\n"
1083
+ . "# to mean any undefined extension.\n"
1084
+ . "#\n"
1085
+ . "# Shebang Strings: [string] [string] ...\n"
1086
+ . "# Defines a list of strings that can appear in the shebang (#!) line to\n"
1087
+ . "# designate that it's part of the language.\n"
1088
+ . "#\n";
1089
+ }
1090
+ else
1091
+ {
1092
+ print FH_LANGUAGES
1093
+ "# [Add/Replace] Extensions: [extension] [extension] ...\n"
1094
+ . "# Defines the file extensions of the language's source files. You can\n"
1095
+ . "# redefine extensions found in the main languages file. You can use * to\n"
1096
+ . "# mean any undefined extension.\n"
1097
+ . "#\n"
1098
+ . "# Shebang Strings: [string] [string] ...\n"
1099
+ . "# [Add/Replace] Shebang Strings: [string] [string] ...\n"
1100
+ . "# Defines a list of strings that can appear in the shebang (#!) line to\n"
1101
+ . "# designate that it's part of the language. You can redefine strings found\n"
1102
+ . "# in the main languages file.\n"
1103
+ . "#\n";
1104
+ };
1105
+
1106
+ print FH_LANGUAGES
1107
+ "# Ignore Prefixes in Index: [prefix] [prefix] ...\n"
1108
+ . (!$isMain ? "# [Add/Replace] Ignored Prefixes in Index: [prefix] [prefix] ...\n#\n" : '')
1109
+ . "# Ignore [Topic Type] Prefixes in Index: [prefix] [prefix] ...\n"
1110
+ . (!$isMain ? "# [Add/Replace] Ignored [Topic Type] Prefixes in Index: [prefix] [prefix] ...\n" : '')
1111
+ . "# Specifies prefixes that should be ignored when sorting symbols in an\n"
1112
+ . "# index. Can be specified in general or for a specific topic type.\n"
1113
+ . "#\n"
1114
+ . "#------------------------------------------------------------------------------\n"
1115
+ . "# For basic language support only:\n"
1116
+ . "#\n"
1117
+ . "# Line Comments: [symbol] [symbol] ...\n"
1118
+ . "# Defines a space-separated list of symbols that are used for line comments,\n"
1119
+ . "# if any.\n"
1120
+ . "#\n"
1121
+ . "# Block Comments: [opening sym] [closing sym] [opening sym] [closing sym] ...\n"
1122
+ . "# Defines a space-separated list of symbol pairs that are used for block\n"
1123
+ . "# comments, if any.\n"
1124
+ . "#\n"
1125
+ . "# Package Separator: [symbol]\n"
1126
+ . "# Defines the default package separator symbol. The default is a dot.\n"
1127
+ . "#\n"
1128
+ . "# [Topic Type] Prototype Enders: [symbol] [symbol] ...\n"
1129
+ . "# When defined, Natural Docs will attempt to get a prototype from the code\n"
1130
+ . "# immediately following the topic type. It stops when it reaches one of\n"
1131
+ . "# these symbols. Use \\n for line breaks.\n"
1132
+ . "#\n"
1133
+ . "# Line Extender: [symbol]\n"
1134
+ . "# Defines the symbol that allows a prototype to span multiple lines if\n"
1135
+ . "# normally a line break would end it.\n"
1136
+ . "#\n"
1137
+ . "# Enum Values: [global|under type|under parent]\n"
1138
+ . "# Defines how enum values are referenced. The default is global.\n"
1139
+ . "# global - Values are always global, referenced as 'value'.\n"
1140
+ . "# under type - Values are under the enum type, referenced as\n"
1141
+ . "# 'package.enum.value'.\n"
1142
+ . "# under parent - Values are under the enum's parent, referenced as\n"
1143
+ . "# 'package.value'.\n"
1144
+ . "#\n"
1145
+ . "# Perl Package: [perl package]\n"
1146
+ . "# Specifies the Perl package used to fine-tune the language behavior in ways\n"
1147
+ . "# too complex to do in this file.\n"
1148
+ . "#\n"
1149
+ . "#------------------------------------------------------------------------------\n"
1150
+ . "# For full language support only:\n"
1151
+ . "#\n"
1152
+ . "# Full Language Support: [perl package]\n"
1153
+ . "# Specifies the Perl package that has the parsing routines necessary for full\n"
1154
+ . "# language support.\n"
1155
+ . "#\n"
1156
+ . "#-------------------------------------------------------------------------------\n\n";
1157
+
1158
+ if ($isMain)
1159
+ {
1160
+ print FH_LANGUAGES
1161
+ "# The following languages MUST be defined in this file:\n"
1162
+ . "#\n"
1163
+ . "# Text File, Shebang Script\n";
1164
+ }
1165
+ else
1166
+ {
1167
+ print FH_LANGUAGES
1168
+ "# The following languages are defined in the main file, if you'd like to alter\n"
1169
+ . "# them:\n"
1170
+ . "#\n"
1171
+ . Text::Wrap::wrap('# ', '# ', join(', ', @mainLanguageNames)) . "\n";
1172
+ };
1173
+
1174
+ print FH_LANGUAGES "\n"
1175
+ . "# If you add a language that you think would be useful to other developers\n"
1176
+ . "# and should be included in Natural Docs by default, please e-mail it to\n"
1177
+ . "# languages [at] naturaldocs [dot] org.\n";
1178
+
1179
+ my @topicTypeOrder = ( ::TOPIC_GENERAL(), ::TOPIC_CLASS(), ::TOPIC_FUNCTION(), ::TOPIC_VARIABLE(),
1180
+ ::TOPIC_PROPERTY(), ::TOPIC_TYPE(), ::TOPIC_CONSTANT() );
1181
+
1182
+ for (my $i = 0; $i < scalar @segments; $i += 3)
1183
+ {
1184
+ my ($keyword, $name, $properties) = @segments[$i..$i+2];
1185
+
1186
+ print FH_LANGUAGES "\n\n";
1187
+
1188
+ if ($keyword eq 'language')
1189
+ { print FH_LANGUAGES 'Language: ' . $name . "\n\n"; }
1190
+ else
1191
+ { print FH_LANGUAGES 'Alter Language: ' . $name . "\n\n"; };
1192
+
1193
+ if (exists $properties->{'extensions'})
1194
+ {
1195
+ print FH_LANGUAGES ' ';
1196
+
1197
+ if ($properties->{'extensions command'})
1198
+ { print FH_LANGUAGES ucfirst($properties->{'extensions command'}) . ' '; };
1199
+
1200
+ my @extensions = split(/ /, $properties->{'extensions'}, 2);
1201
+
1202
+ if (scalar @extensions == 1)
1203
+ { print FH_LANGUAGES 'Extension: '; }
1204
+ else
1205
+ { print FH_LANGUAGES 'Extensions: '; };
1206
+
1207
+ print FH_LANGUAGES lc($properties->{'extensions'}) . "\n";
1208
+ };
1209
+
1210
+ if (exists $properties->{'shebang strings'})
1211
+ {
1212
+ print FH_LANGUAGES ' ';
1213
+
1214
+ if ($properties->{'shebang strings command'})
1215
+ { print FH_LANGUAGES ucfirst($properties->{'shebang strings command'}) . ' '; };
1216
+
1217
+ my @shebangStrings = split(/ /, $properties->{'shebang strings'}, 2);
1218
+
1219
+ if (scalar @shebangStrings == 1)
1220
+ { print FH_LANGUAGES 'Shebang String: '; }
1221
+ else
1222
+ { print FH_LANGUAGES 'Shebang Strings: '; };
1223
+
1224
+ print FH_LANGUAGES lc($properties->{'shebang strings'}) . "\n";
1225
+ };
1226
+
1227
+ if (exists $properties->{'ignored prefixes in index'})
1228
+ {
1229
+ my $topicTypePrefixes = $properties->{'ignored prefixes in index'};
1230
+
1231
+ my %usedTopicTypes;
1232
+ my @topicTypes = ( @topicTypeOrder, keys %$topicTypePrefixes );
1233
+
1234
+ foreach my $topicType (@topicTypes)
1235
+ {
1236
+ if ($topicType !~ / command$/ &&
1237
+ exists $topicTypePrefixes->{$topicType} &&
1238
+ !exists $usedTopicTypes{$topicType})
1239
+ {
1240
+ print FH_LANGUAGES ' ';
1241
+
1242
+ if ($topicTypePrefixes->{$topicType . ' command'})
1243
+ { print FH_LANGUAGES ucfirst($topicTypePrefixes->{$topicType . ' command'}) . ' Ignored '; }
1244
+ else
1245
+ { print FH_LANGUAGES 'Ignore '; };
1246
+
1247
+ if ($topicType ne ::TOPIC_GENERAL())
1248
+ { print FH_LANGUAGES NaturalDocs::Topics->TypeInfo($topicType)->Name() . ' '; };
1249
+
1250
+ my @prefixes = split(/ /, $topicTypePrefixes->{$topicType}, 2);
1251
+
1252
+ if (scalar @prefixes == 1)
1253
+ { print FH_LANGUAGES 'Prefix in Index: '; }
1254
+ else
1255
+ { print FH_LANGUAGES 'Prefixes in Index: '; };
1256
+
1257
+ print FH_LANGUAGES $topicTypePrefixes->{$topicType} . "\n";
1258
+
1259
+ $usedTopicTypes{$topicType} = 1;
1260
+ };
1261
+ };
1262
+ };
1263
+
1264
+ if (exists $properties->{'line comments'})
1265
+ {
1266
+ my @comments = split(/ /, $properties->{'line comments'}, 2);
1267
+
1268
+ if (scalar @comments == 1)
1269
+ { print FH_LANGUAGES ' Line Comment: '; }
1270
+ else
1271
+ { print FH_LANGUAGES ' Line Comments: '; };
1272
+
1273
+ print FH_LANGUAGES $properties->{'line comments'} . "\n";
1274
+ };
1275
+
1276
+ if (exists $properties->{'block comments'})
1277
+ {
1278
+ my @comments = split(/ /, $properties->{'block comments'}, 3);
1279
+
1280
+ if (scalar @comments == 2)
1281
+ { print FH_LANGUAGES ' Block Comment: '; }
1282
+ else
1283
+ { print FH_LANGUAGES ' Block Comments: '; };
1284
+
1285
+ print FH_LANGUAGES $properties->{'block comments'} . "\n";
1286
+ };
1287
+
1288
+ if (exists $properties->{'package separator'})
1289
+ {
1290
+ # Prior to 1.32, Package Separator was allowed for full language support. Ignore it when reformatting.
1291
+ if ($version >= NaturalDocs::Version->FromString('1.32') || !exists $properties->{'full language support'})
1292
+ { print FH_LANGUAGES ' Package Separator: ' . $properties->{'package separator'} . "\n"; };
1293
+ };
1294
+
1295
+ if (exists $properties->{'enum values'})
1296
+ {
1297
+ print FH_LANGUAGES ' Enum Values: ' . ucfirst(lc($properties->{'enum values'})) . "\n";
1298
+ };
1299
+
1300
+ if (exists $properties->{'prototype enders'})
1301
+ {
1302
+ my $topicTypeEnders = $properties->{'prototype enders'};
1303
+
1304
+ my %usedTopicTypes;
1305
+ my @topicTypes = ( @topicTypeOrder, keys %$topicTypeEnders );
1306
+
1307
+ foreach my $topicType (@topicTypes)
1308
+ {
1309
+ if ($topicType !~ / command$/ &&
1310
+ exists $topicTypeEnders->{$topicType} &&
1311
+ !exists $usedTopicTypes{$topicType})
1312
+ {
1313
+ print FH_LANGUAGES ' ';
1314
+
1315
+ if ($topicType ne ::TOPIC_GENERAL())
1316
+ { print FH_LANGUAGES NaturalDocs::Topics->TypeInfo($topicType)->Name() . ' '; };
1317
+
1318
+ my @enders = split(/ /, $topicTypeEnders->{$topicType}, 2);
1319
+
1320
+ if (scalar @enders == 1)
1321
+ { print FH_LANGUAGES 'Prototype Ender: '; }
1322
+ else
1323
+ { print FH_LANGUAGES 'Prototype Enders: '; };
1324
+
1325
+ print FH_LANGUAGES $topicTypeEnders->{$topicType} . "\n";
1326
+
1327
+ $usedTopicTypes{$topicType} = 1;
1328
+ };
1329
+ };
1330
+ };
1331
+
1332
+ if (exists $properties->{'line extender'})
1333
+ {
1334
+ print FH_LANGUAGES ' Line Extender: ' . $properties->{'line extender'} . "\n";
1335
+ };
1336
+
1337
+ if (exists $properties->{'perl package'})
1338
+ {
1339
+ print FH_LANGUAGES ' Perl Package: ' . $properties->{'perl package'} . "\n";
1340
+ };
1341
+
1342
+ if (exists $properties->{'full language support'})
1343
+ {
1344
+ print FH_LANGUAGES ' Full Language Support: ' . $properties->{'full language support'} . "\n";
1345
+ };
1346
+ };
1347
+
1348
+ close(FH_LANGUAGES);
1349
+ };
1350
+
1351
+
1352
+
1353
+ ###############################################################################
1354
+ # Group: Functions
1355
+
1356
+
1357
+ #
1358
+ # Function: LanguageOf
1359
+ #
1360
+ # Returns the language of the passed source file.
1361
+ #
1362
+ # Parameters:
1363
+ #
1364
+ # sourceFile - The source <FileName> to get the language of.
1365
+ #
1366
+ # Returns:
1367
+ #
1368
+ # A <NaturalDocs::Languages::Base>-derived object for the passed file, or undef if the file is not a recognized language.
1369
+ #
1370
+ sub LanguageOf #(sourceFile)
1371
+ {
1372
+ my ($self, $sourceFile) = @_;
1373
+
1374
+ my $extension = NaturalDocs::File->ExtensionOf($sourceFile);
1375
+ if (defined $extension)
1376
+ { $extension = lc($extension); };
1377
+
1378
+ my $languageName;
1379
+
1380
+ if (!defined $extension)
1381
+ { $languageName = 'shebang script'; }
1382
+ else
1383
+ { $languageName = $extensions{$extension}; };
1384
+
1385
+ if (!defined $languageName)
1386
+ { $languageName = $extensions{'*'}; };
1387
+
1388
+ if (defined $languageName)
1389
+ {
1390
+ if ($languageName eq 'shebang script')
1391
+ {
1392
+ if (exists $shebangFiles{$sourceFile})
1393
+ {
1394
+ if (defined $shebangFiles{$sourceFile})
1395
+ { return $languages{$shebangFiles{$sourceFile}}; }
1396
+ else
1397
+ { return undef; };
1398
+ }
1399
+
1400
+ else # (!exists $shebangFiles{$sourceFile})
1401
+ {
1402
+ my $shebangLine;
1403
+
1404
+ if (open(SOURCEFILEHANDLE, '<' . $sourceFile))
1405
+ {
1406
+ read(SOURCEFILEHANDLE, $shebangLine, 2);
1407
+ if ($shebangLine eq '#!')
1408
+ { $shebangLine = <SOURCEFILEHANDLE>; }
1409
+ else
1410
+ { $shebangLine = undef; };
1411
+
1412
+ close (SOURCEFILEHANDLE);
1413
+ }
1414
+ elsif (defined $extension)
1415
+ { die 'Could not open ' . $sourceFile; }
1416
+ # Ignore extensionless files that can't be opened. They may be system files.
1417
+
1418
+ if (!defined $shebangLine)
1419
+ {
1420
+ $shebangFiles{$sourceFile} = undef;
1421
+ return undef;
1422
+ }
1423
+ else
1424
+ {
1425
+ $shebangLine = lc($shebangLine);
1426
+
1427
+ foreach my $shebangString (keys %shebangStrings)
1428
+ {
1429
+ if (index($shebangLine, $shebangString) != -1)
1430
+ {
1431
+ $shebangFiles{$sourceFile} = $shebangStrings{$shebangString};
1432
+ return $languages{$shebangStrings{$shebangString}};
1433
+ };
1434
+ };
1435
+
1436
+ $shebangFiles{$sourceFile} = undef;
1437
+ return undef;
1438
+ };
1439
+ };
1440
+ }
1441
+
1442
+ else # language name ne 'shebang script'
1443
+ { return $languages{$languageName}; };
1444
+ }
1445
+ else # !defined $language
1446
+ {
1447
+ return undef;
1448
+ };
1449
+ };
1450
+
1451
+
1452
+ #
1453
+ # Function: OnMostUsedLanguageKnown
1454
+ #
1455
+ # Called when the most used language is known.
1456
+ #
1457
+ sub OnMostUsedLanguageKnown
1458
+ {
1459
+ my $self = shift;
1460
+
1461
+ my $language = $languages{lc( NaturalDocs::Project->MostUsedLanguage() )};
1462
+
1463
+ if ($language)
1464
+ {
1465
+ if (!$languages{'text file'}->HasIgnoredPrefixes())
1466
+ { $languages{'text file'}->CopyIgnoredPrefixesOf($language); };
1467
+ if (!$languages{'text file'}->PackageSeparatorWasSet())
1468
+ { $languages{'text file'}->SetPackageSeparator($language->PackageSeparator()); };
1469
+ if (!$languages{'text file'}->EnumValuesWasSet())
1470
+ { $languages{'text file'}->SetEnumValues($language->EnumValues()); };
1471
+ };
1472
+ };
1473
+
1474
+
1475
+ 1;