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.
- data/LICENSE +20 -0
- data/README.markdown +49 -0
- data/VERSION +1 -0
- data/bin/bixbite +73 -0
- data/lib/bixbite.rb +13 -0
- data/lib/bixbite/command.rb +14 -0
- data/lib/bixbite/create.rb +76 -0
- data/template/Rakefile +25 -0
- data/template/assets/bixbite/Rakefile.rb +297 -0
- data/template/assets/naturaldocs/NaturalDocs/Config/Languages.txt +286 -0
- data/template/assets/naturaldocs/NaturalDocs/Config/Topics.txt +382 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/customizinglanguages.html +52 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/customizingtopics.html +74 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/documenting.html +58 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/documenting/reference.html +146 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/documenting/walkthrough.html +180 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/example/Default.css +528 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/example/NaturalDocs.js +204 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/examples.css +90 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/images/header/background.png +0 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/images/header/leftside.png +0 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/images/header/logo.png +0 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/images/header/overbody.png +0 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/images/header/overbodybg.png +0 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/images/header/overleftmargin.png +0 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/images/header/overmenu.png +0 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/images/header/overmenubg.png +0 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/images/header/rightside.png +0 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/images/logo.gif +0 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/images/menu/about.png +0 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/images/menu/background.png +0 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/images/menu/bottomleft.png +0 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/images/menu/bottomright.png +0 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/images/menu/community.png +0 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/images/menu/customizing.png +0 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/images/menu/using.png +0 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/index.html +9 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/javascript/BrowserStyles.js +77 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/javascript/PNGHandling.js +72 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/keywords.html +38 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/languages.html +32 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/menu.html +79 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/output.html +84 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/running.html +40 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/styles.css +290 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/styles.html +52 -0
- data/template/assets/naturaldocs/NaturalDocs/Help/troubleshooting.html +18 -0
- data/template/assets/naturaldocs/NaturalDocs/Info/CSSGuide.txt +947 -0
- data/template/assets/naturaldocs/NaturalDocs/Info/File Parsing.txt +83 -0
- data/template/assets/naturaldocs/NaturalDocs/Info/HTMLTestCases.pm +269 -0
- data/template/assets/naturaldocs/NaturalDocs/Info/Languages.txt +107 -0
- data/template/assets/naturaldocs/NaturalDocs/Info/NDMarkup.txt +91 -0
- data/template/assets/naturaldocs/NaturalDocs/Info/Symbol Management.txt +59 -0
- data/template/assets/naturaldocs/NaturalDocs/Info/images/Logo.png +0 -0
- data/template/assets/naturaldocs/NaturalDocs/JavaScript/NaturalDocs.js +836 -0
- data/template/assets/naturaldocs/NaturalDocs/License-GPL.txt +341 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/BinaryFile.pm +294 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Builder.pm +280 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Builder/Base.pm +348 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Builder/FramedHTML.pm +345 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Builder/HTML.pm +398 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Builder/HTMLBase.pm +3693 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/ClassHierarchy.pm +860 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/ClassHierarchy/Class.pm +412 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/ClassHierarchy/File.pm +157 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/ConfigFile.pm +497 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Constants.pm +165 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/DefineMembers.pm +100 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Error.pm +305 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/File.pm +540 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/ImageReferenceTable.pm +383 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/ImageReferenceTable/Reference.pm +44 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/ImageReferenceTable/String.pm +110 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages.pm +1475 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/ActionScript.pm +1473 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Ada.pm +38 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Advanced.pm +828 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Advanced/Scope.pm +95 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Advanced/ScopeChange.pm +70 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Base.pm +832 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/CSharp.pm +1484 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/PLSQL.pm +319 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Pascal.pm +143 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Perl.pm +1370 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Prototype.pm +92 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Prototype/Parameter.pm +87 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Simple.pm +503 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Languages/Tcl.pm +219 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Menu.pm +3406 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Menu/Entry.pm +201 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/NDMarkup.pm +76 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Parser.pm +1331 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Parser/JavaDoc.pm +464 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Parser/Native.pm +1060 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Parser/ParsedTopic.pm +253 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Project.pm +1402 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Project/ImageFile.pm +160 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Project/SourceFile.pm +113 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/ReferenceString.pm +334 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Settings.pm +1418 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Settings/BuildTarget.pm +66 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SourceDB.pm +678 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SourceDB/Extension.pm +84 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SourceDB/File.pm +129 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SourceDB/Item.pm +201 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SourceDB/ItemDefinition.pm +45 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SourceDB/WatchedFileDefinitions.pm +159 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/StatusMessage.pm +102 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SymbolString.pm +212 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SymbolTable.pm +1984 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SymbolTable/File.pm +186 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SymbolTable/IndexElement.pm +522 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SymbolTable/Reference.pm +273 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SymbolTable/ReferenceTarget.pm +97 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SymbolTable/Symbol.pm +428 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/SymbolTable/SymbolDefinition.pm +96 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Topics.pm +1319 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Topics/Type.pm +151 -0
- data/template/assets/naturaldocs/NaturalDocs/Modules/NaturalDocs/Version.pm +384 -0
- data/template/assets/naturaldocs/NaturalDocs/NaturalDocs +400 -0
- data/template/assets/naturaldocs/NaturalDocs/NaturalDocs.bat +17 -0
- data/template/assets/naturaldocs/NaturalDocs/Styles/Default.css +767 -0
- data/template/assets/naturaldocs/NaturalDocs/Styles/Roman.css +765 -0
- data/template/assets/naturaldocs/NaturalDocs/Styles/Small.css +763 -0
- data/template/assets/utilities/pngout +0 -0
- data/template/deploy/public_html/.htaccess +0 -0
- data/template/documentation/js/.htaccess +0 -0
- data/template/src/html/.htaccess +76 -0
- data/template/src/html/css/cmn/global.css +96 -0
- data/template/src/html/css/cmn/ie.css +15 -0
- data/template/src/html/css/cmn/ie6.css +15 -0
- data/template/src/html/images/cmn/.htaccess +0 -0
- data/template/src/html/images/tmp/.htaccess +0 -0
- data/template/src/html/includes/debug.inc +5 -0
- data/template/src/html/includes/footer.inc +52 -0
- data/template/src/html/includes/header.inc +61 -0
- data/template/src/html/includes/html.inc +3 -0
- data/template/src/html/includes/namespace.inc +19 -0
- data/template/src/html/includes/page.inc +151 -0
- data/template/src/html/index.html +35 -0
- data/template/src/html/js/cmn/bootstrap.js +74 -0
- data/template/src/html/js/cmn/global.js +142 -0
- data/template/src/html/js/cmn/lib/LAB.js +348 -0
- data/template/src/html/min/.htaccess +4 -0
- data/template/src/html/min/MinifyCLI.php +19 -0
- data/template/src/html/min/README.txt +132 -0
- data/template/src/html/min/builder/_index.js +242 -0
- data/template/src/html/min/builder/bm.js +36 -0
- data/template/src/html/min/builder/index.php +182 -0
- data/template/src/html/min/builder/ocCheck.php +36 -0
- data/template/src/html/min/builder/rewriteTest.js +1 -0
- data/template/src/html/min/config.php +187 -0
- data/template/src/html/min/groupsConfig.php +34 -0
- data/template/src/html/min/index.php +66 -0
- data/template/src/html/min/lib/FirePHP.php +1370 -0
- data/template/src/html/min/lib/HTTP/ConditionalGet.php +348 -0
- data/template/src/html/min/lib/HTTP/Encoder.php +326 -0
- data/template/src/html/min/lib/JSMin.php +314 -0
- data/template/src/html/min/lib/JSMinPlus.php +1872 -0
- data/template/src/html/min/lib/Minify.php +532 -0
- data/template/src/html/min/lib/Minify/Build.php +103 -0
- data/template/src/html/min/lib/Minify/CSS.php +83 -0
- data/template/src/html/min/lib/Minify/CSS/Compressor.php +250 -0
- data/template/src/html/min/lib/Minify/CSS/UriRewriter.php +270 -0
- data/template/src/html/min/lib/Minify/Cache/APC.php +130 -0
- data/template/src/html/min/lib/Minify/Cache/File.php +125 -0
- data/template/src/html/min/lib/Minify/Cache/Memcache.php +137 -0
- data/template/src/html/min/lib/Minify/ClosureCompiler.php +85 -0
- data/template/src/html/min/lib/Minify/CommentPreserver.php +90 -0
- data/template/src/html/min/lib/Minify/Controller/Base.php +202 -0
- data/template/src/html/min/lib/Minify/Controller/Files.php +78 -0
- data/template/src/html/min/lib/Minify/Controller/Groups.php +94 -0
- data/template/src/html/min/lib/Minify/Controller/MinApp.php +132 -0
- data/template/src/html/min/lib/Minify/Controller/Page.php +82 -0
- data/template/src/html/min/lib/Minify/Controller/Version1.php +118 -0
- data/template/src/html/min/lib/Minify/HTML.php +245 -0
- data/template/src/html/min/lib/Minify/ImportProcessor.php +157 -0
- data/template/src/html/min/lib/Minify/Lines.php +131 -0
- data/template/src/html/min/lib/Minify/Logger.php +45 -0
- data/template/src/html/min/lib/Minify/Packer.php +37 -0
- data/template/src/html/min/lib/Minify/Source.php +187 -0
- data/template/src/html/min/lib/Minify/YUICompressor.php +139 -0
- data/template/src/html/min/lib/Solar/Dir.php +199 -0
- data/template/src/html/min/lib/closure-compiler.jar +0 -0
- data/template/src/html/min/lib/yuicompressor-2.4.2.jar +0 -0
- data/template/src/html/min/utils.php +90 -0
- data/template/src/templates/css/template.css +7 -0
- data/template/src/templates/js/template.js +72 -0
- data/template/src/templates/template.html +18 -0
- data/template/src/yaml/config.yml +46 -0
- data/template/src/yaml/deploy.yml +35 -0
- data/test/bixbite_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +278 -0
@@ -0,0 +1,497 @@
|
|
1
|
+
###############################################################################
|
2
|
+
#
|
3
|
+
# Package: NaturalDocs::ConfigFile
|
4
|
+
#
|
5
|
+
###############################################################################
|
6
|
+
#
|
7
|
+
# A package to manage Natural Docs' configuration files.
|
8
|
+
#
|
9
|
+
# Usage:
|
10
|
+
#
|
11
|
+
# - Only one configuration file can be managed with this package at a time. You must close the file before opening another
|
12
|
+
# one.
|
13
|
+
#
|
14
|
+
###############################################################################
|
15
|
+
|
16
|
+
# This file is part of Natural Docs, which is Copyright (C) 2003-2008 Greg Valure
|
17
|
+
# Natural Docs is licensed under the GPL
|
18
|
+
|
19
|
+
use strict;
|
20
|
+
use integer;
|
21
|
+
|
22
|
+
package NaturalDocs::ConfigFile;
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
#
|
27
|
+
# Topic: Format
|
28
|
+
#
|
29
|
+
# All configuration files are text files.
|
30
|
+
#
|
31
|
+
# > # [comment]
|
32
|
+
#
|
33
|
+
# Comments start with the # character.
|
34
|
+
#
|
35
|
+
# > Format: [version]
|
36
|
+
#
|
37
|
+
# All configuration files *must* have a format line as its first line containing content. Whitespace and comments are permitted
|
38
|
+
# ahead of it.
|
39
|
+
#
|
40
|
+
# > [keyword]: [value]
|
41
|
+
#
|
42
|
+
# Keywords can only contain <CFChars>. Keywords are not case sensitive. Values can be anything and run until the end of
|
43
|
+
# the line or a comment.
|
44
|
+
#
|
45
|
+
# > [value]
|
46
|
+
#
|
47
|
+
# Lines that don't start with a valid keyword format are considered to be all value.
|
48
|
+
#
|
49
|
+
# > [line] { [line] } [line]
|
50
|
+
#
|
51
|
+
# Files supporting brace groups (specified in <Open()>) may also have braces that can appear anywhere. It allows more than
|
52
|
+
# one thing to appear per line, which isn't supported otherwise. Consequently, values may not have braces.
|
53
|
+
#
|
54
|
+
|
55
|
+
|
56
|
+
#
|
57
|
+
# Type: CFChars
|
58
|
+
#
|
59
|
+
# The characters that can appear in configuration file keywords and user-defined element names: letters, numbers, spaces,
|
60
|
+
# dashes, slashes, apostrophes, and periods.
|
61
|
+
#
|
62
|
+
# Although the list above is exhaustive, it should be noted that you especially can *not* use colons (messes up keyword: value
|
63
|
+
# sequences) commas (messes up item, item, item list sequences) and hashes (messes up comment detection.)
|
64
|
+
#
|
65
|
+
# You can search the source code for [CFChars] to find all the instances where this definition is used.
|
66
|
+
#
|
67
|
+
|
68
|
+
|
69
|
+
###############################################################################
|
70
|
+
# Group: Variables
|
71
|
+
|
72
|
+
#
|
73
|
+
# handle: CONFIG_FILEHANDLE
|
74
|
+
#
|
75
|
+
# The file handle used for the configuration file.
|
76
|
+
#
|
77
|
+
|
78
|
+
|
79
|
+
#
|
80
|
+
# string: file
|
81
|
+
#
|
82
|
+
# The <FileName> for the current configuration file being parsed.
|
83
|
+
#
|
84
|
+
my $file;
|
85
|
+
|
86
|
+
|
87
|
+
#
|
88
|
+
# array: errors
|
89
|
+
#
|
90
|
+
# An array of errors added by <AddError()>. Every odd entry is the line number, and every even entry following is the
|
91
|
+
# error message.
|
92
|
+
#
|
93
|
+
my @errors;
|
94
|
+
|
95
|
+
|
96
|
+
#
|
97
|
+
# var: lineNumber
|
98
|
+
#
|
99
|
+
# The current line number for the configuration file.
|
100
|
+
#
|
101
|
+
my $lineNumber;
|
102
|
+
|
103
|
+
|
104
|
+
#
|
105
|
+
# bool: hasBraceGroups
|
106
|
+
#
|
107
|
+
# Whether the file has brace groups or not.
|
108
|
+
#
|
109
|
+
my $hasBraceGroups;
|
110
|
+
|
111
|
+
|
112
|
+
#
|
113
|
+
# array: virtualLines
|
114
|
+
#
|
115
|
+
# An array of virtual lines if a line from the file contained more than one.
|
116
|
+
#
|
117
|
+
# Files with brace groups may have more than one virtual line per actual file line, such as "Group: A { Group: B". When that
|
118
|
+
# happens, any extra virtual lines are put into here so they can be returned on the next call.
|
119
|
+
#
|
120
|
+
my @virtualLines;
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
###############################################################################
|
125
|
+
# Group: Functions
|
126
|
+
|
127
|
+
|
128
|
+
#
|
129
|
+
# Function: Open
|
130
|
+
#
|
131
|
+
# Opens a configuration file for parsing and returns the format <VersionInt>.
|
132
|
+
#
|
133
|
+
# Parameters:
|
134
|
+
#
|
135
|
+
# file - The <FileName> to parse.
|
136
|
+
# hasBraceGroups - Whether the file supports brace groups or not. If so, lines with braces will be split apart behind the
|
137
|
+
# scenes.
|
138
|
+
#
|
139
|
+
# Returns:
|
140
|
+
#
|
141
|
+
# The <VersionInt> of the file, or undef if the file doesn't exist.
|
142
|
+
#
|
143
|
+
sub Open #(file, hasBraceGroups)
|
144
|
+
{
|
145
|
+
my $self;
|
146
|
+
($self, $file, $hasBraceGroups) = @_;
|
147
|
+
|
148
|
+
@errors = ( );
|
149
|
+
|
150
|
+
# It will be incremented to one when the first line is read from the file.
|
151
|
+
$lineNumber = 0;
|
152
|
+
|
153
|
+
open(CONFIG_FILEHANDLE, '<' . $file) or return undef;
|
154
|
+
|
155
|
+
|
156
|
+
# Get the format line.
|
157
|
+
|
158
|
+
my ($keyword, $value, $comment) = $self->GetLine();
|
159
|
+
|
160
|
+
if ($keyword eq 'format')
|
161
|
+
{ return NaturalDocs::Version->FromString($value); }
|
162
|
+
else
|
163
|
+
{ die "The first content line in " . $file . " must be the Format: line.\n"; };
|
164
|
+
};
|
165
|
+
|
166
|
+
|
167
|
+
#
|
168
|
+
# Function: Close
|
169
|
+
#
|
170
|
+
# Closes the current configuration file.
|
171
|
+
#
|
172
|
+
sub Close
|
173
|
+
{
|
174
|
+
my $self = shift;
|
175
|
+
close(CONFIG_FILEHANDLE);
|
176
|
+
};
|
177
|
+
|
178
|
+
|
179
|
+
#
|
180
|
+
# Function: GetLine
|
181
|
+
#
|
182
|
+
# Returns the next line containing content, or an empty array if none.
|
183
|
+
#
|
184
|
+
# Returns:
|
185
|
+
#
|
186
|
+
# Returns the array ( keyword, value, comment ), or an empty array if none. All tabs will be converted to spaces, and all
|
187
|
+
# whitespace will be condensed into a single space.
|
188
|
+
#
|
189
|
+
# keyword - The keyword part of the line, if any. Is converted to lowercase and doesn't include the colon. If the file supports
|
190
|
+
# brace groups, opening and closing braces will be returned as keywords.
|
191
|
+
# value - The value part of the line, minus any whitespace. Keeps its original case.
|
192
|
+
# comment - The comment following the line, if any. This includes the # symbol and a leading space if there was
|
193
|
+
# any whitespace, since it may be significant. Otherwise undef. Used for lines where the # character needs to be
|
194
|
+
# accepted as part of the value.
|
195
|
+
#
|
196
|
+
sub GetLine
|
197
|
+
{
|
198
|
+
my $self = shift;
|
199
|
+
|
200
|
+
my ($line, $comment);
|
201
|
+
|
202
|
+
|
203
|
+
# Get the next line with content.
|
204
|
+
|
205
|
+
do
|
206
|
+
{
|
207
|
+
# Get the next line.
|
208
|
+
|
209
|
+
my $isFileLine;
|
210
|
+
|
211
|
+
if (scalar @virtualLines)
|
212
|
+
{
|
213
|
+
$line = shift @virtualLines;
|
214
|
+
$isFileLine = 0;
|
215
|
+
}
|
216
|
+
else
|
217
|
+
{
|
218
|
+
$line = <CONFIG_FILEHANDLE>;
|
219
|
+
$lineNumber++;
|
220
|
+
|
221
|
+
if (!defined $line)
|
222
|
+
{ return ( ); };
|
223
|
+
|
224
|
+
::XChomp(\$line);
|
225
|
+
|
226
|
+
# Condense spaces and tabs into a single space.
|
227
|
+
$line =~ tr/\t / /s;
|
228
|
+
$isFileLine = 1;
|
229
|
+
};
|
230
|
+
|
231
|
+
|
232
|
+
# Split off the comment.
|
233
|
+
|
234
|
+
if ($line =~ /^(.*?)( ?#.*)$/)
|
235
|
+
{ ($line, $comment) = ($1, $2); }
|
236
|
+
else
|
237
|
+
{ $comment = undef; };
|
238
|
+
|
239
|
+
|
240
|
+
# Split any brace groups.
|
241
|
+
|
242
|
+
if ($isFileLine && $hasBraceGroups && $line =~ /[\{\}]/)
|
243
|
+
{
|
244
|
+
($line, @virtualLines) = split(/([\{\}])/, $line);
|
245
|
+
|
246
|
+
$virtualLines[-1] .= $comment;
|
247
|
+
$comment = undef;
|
248
|
+
};
|
249
|
+
|
250
|
+
|
251
|
+
# Remove whitespace.
|
252
|
+
|
253
|
+
$line =~ s/^ //;
|
254
|
+
$line =~ s/ $//;
|
255
|
+
$comment =~ s/ $//;
|
256
|
+
# We want to keep the leading space on a comment.
|
257
|
+
}
|
258
|
+
while (!$line);
|
259
|
+
|
260
|
+
|
261
|
+
# Process the line.
|
262
|
+
|
263
|
+
if ($hasBraceGroups && ($line eq '{' || $line eq '}'))
|
264
|
+
{
|
265
|
+
return ($line, undef, undef);
|
266
|
+
};
|
267
|
+
|
268
|
+
|
269
|
+
if ($line =~ /^([a-z0-9\ \'\/\.\-]+?) ?: ?(.*)$/i) # [CFChars]
|
270
|
+
{
|
271
|
+
my ($keyword, $value) = ($1, $2);
|
272
|
+
return (lc($keyword), $value, $comment);
|
273
|
+
}
|
274
|
+
|
275
|
+
else
|
276
|
+
{
|
277
|
+
return (undef, $line, $comment);
|
278
|
+
};
|
279
|
+
};
|
280
|
+
|
281
|
+
|
282
|
+
#
|
283
|
+
# Function: LineNumber
|
284
|
+
#
|
285
|
+
# Returns the line number for the line last returned by <GetLine()>.
|
286
|
+
#
|
287
|
+
sub LineNumber
|
288
|
+
{ return $lineNumber; };
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
###############################################################################
|
293
|
+
# Group: Error Functions
|
294
|
+
|
295
|
+
|
296
|
+
#
|
297
|
+
# Function: AddError
|
298
|
+
#
|
299
|
+
# Stores an error for the current configuration file. Will be attached to the last line read by <GetLine()>.
|
300
|
+
#
|
301
|
+
# Parameters:
|
302
|
+
#
|
303
|
+
# message - The error message.
|
304
|
+
# lineNumber - The line number to use. If not specified, it will use the line number from the last call to <GetLine()>.
|
305
|
+
#
|
306
|
+
sub AddError #(message, lineNumber)
|
307
|
+
{
|
308
|
+
my ($self, $message, $messageLineNumber) = @_;
|
309
|
+
|
310
|
+
if (!defined $messageLineNumber)
|
311
|
+
{ $messageLineNumber = $lineNumber; };
|
312
|
+
|
313
|
+
push @errors, $messageLineNumber, $message;
|
314
|
+
};
|
315
|
+
|
316
|
+
|
317
|
+
#
|
318
|
+
# Function: ErrorCount
|
319
|
+
#
|
320
|
+
# Returns how many errors the configuration file has.
|
321
|
+
#
|
322
|
+
sub ErrorCount
|
323
|
+
{
|
324
|
+
return (scalar @errors) / 2;
|
325
|
+
};
|
326
|
+
|
327
|
+
|
328
|
+
#
|
329
|
+
# Function: PrintErrorsAndAnnotateFile
|
330
|
+
#
|
331
|
+
# Prints the errors to STDERR in the standard GNU format and annotates the configuration file with them. It does *not* end
|
332
|
+
# execution. <Close()> *must* be called before this function.
|
333
|
+
#
|
334
|
+
sub PrintErrorsAndAnnotateFile
|
335
|
+
{
|
336
|
+
my ($self) = @_;
|
337
|
+
|
338
|
+
if (scalar @errors)
|
339
|
+
{
|
340
|
+
open(CONFIG_FILEHANDLE, '<' . $file);
|
341
|
+
my @lines = <CONFIG_FILEHANDLE>;
|
342
|
+
close(CONFIG_FILEHANDLE);
|
343
|
+
|
344
|
+
# We need to keep track of both the real and the original line numbers. The original line numbers are for matching errors in
|
345
|
+
# the errors array, and don't include any comment lines added or deleted. Line number is the current line number including
|
346
|
+
# those comment lines for sending to the display.
|
347
|
+
my $lineNumber = 1;
|
348
|
+
my $originalLineNumber = 1;
|
349
|
+
|
350
|
+
open(CONFIG_FILEHANDLE, '>' . $file);
|
351
|
+
|
352
|
+
# We don't want to keep the old error header, if present.
|
353
|
+
if ($lines[0] =~ /^\# There (?:is an error|are \d+ errors) in this file\./)
|
354
|
+
{
|
355
|
+
shift @lines;
|
356
|
+
$originalLineNumber++;
|
357
|
+
|
358
|
+
# We want to drop the blank line after it as well.
|
359
|
+
if ($lines[0] eq "\n")
|
360
|
+
{
|
361
|
+
shift @lines;
|
362
|
+
$originalLineNumber++;
|
363
|
+
};
|
364
|
+
};
|
365
|
+
|
366
|
+
if ($self->ErrorCount() == 1)
|
367
|
+
{
|
368
|
+
print CONFIG_FILEHANDLE
|
369
|
+
"# There is an error in this file. Search for ERROR to find it.\n\n";
|
370
|
+
}
|
371
|
+
else
|
372
|
+
{
|
373
|
+
print CONFIG_FILEHANDLE
|
374
|
+
"# There are " . $self->ErrorCount() . " errors in this file. Search for ERROR to find them.\n\n";
|
375
|
+
};
|
376
|
+
|
377
|
+
$lineNumber += 2;
|
378
|
+
|
379
|
+
|
380
|
+
foreach my $line (@lines)
|
381
|
+
{
|
382
|
+
while (scalar @errors && $originalLineNumber == $errors[0])
|
383
|
+
{
|
384
|
+
my $errorLine = shift @errors;
|
385
|
+
my $errorMessage = shift @errors;
|
386
|
+
|
387
|
+
print CONFIG_FILEHANDLE "# ERROR: " . $errorMessage . "\n";
|
388
|
+
|
389
|
+
# Use the GNU error format, which should make it easier to handle errors when Natural Docs is part of a build process.
|
390
|
+
# See http://www.gnu.org/prep/standards_15.html
|
391
|
+
|
392
|
+
$errorMessage = lcfirst($errorMessage);
|
393
|
+
$errorMessage =~ s/\.$//;
|
394
|
+
|
395
|
+
print STDERR 'NaturalDocs:' . $file . ':' . $lineNumber . ': ' . $errorMessage . "\n";
|
396
|
+
|
397
|
+
$lineNumber++;
|
398
|
+
};
|
399
|
+
|
400
|
+
# We want to remove error lines from previous runs.
|
401
|
+
if (substr($line, 0, 9) ne '# ERROR: ')
|
402
|
+
{
|
403
|
+
print CONFIG_FILEHANDLE $line;
|
404
|
+
$lineNumber++;
|
405
|
+
};
|
406
|
+
|
407
|
+
$originalLineNumber++;
|
408
|
+
};
|
409
|
+
|
410
|
+
# Clean up any remaining errors.
|
411
|
+
while (scalar @errors)
|
412
|
+
{
|
413
|
+
my $errorLine = shift @errors;
|
414
|
+
my $errorMessage = shift @errors;
|
415
|
+
|
416
|
+
print CONFIG_FILEHANDLE "# ERROR: " . $errorMessage . "\n";
|
417
|
+
|
418
|
+
# Use the GNU error format, which should make it easier to handle errors when Natural Docs is part of a build process.
|
419
|
+
# See http://www.gnu.org/prep/standards_15.html
|
420
|
+
|
421
|
+
$errorMessage = lcfirst($errorMessage);
|
422
|
+
$errorMessage =~ s/\.$//;
|
423
|
+
|
424
|
+
print STDERR 'NaturalDocs:' . $file . ':' . $lineNumber . ': ' . $errorMessage . "\n";
|
425
|
+
};
|
426
|
+
|
427
|
+
close(CONFIG_FILEHANDLE);
|
428
|
+
};
|
429
|
+
};
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
###############################################################################
|
434
|
+
# Group: Misc Functions
|
435
|
+
|
436
|
+
|
437
|
+
#
|
438
|
+
# Function: HasOnlyCFChars
|
439
|
+
#
|
440
|
+
# Returns whether the passed string contains only <CFChars>.
|
441
|
+
#
|
442
|
+
sub HasOnlyCFChars #(string)
|
443
|
+
{
|
444
|
+
my ($self, $string) = @_;
|
445
|
+
return ($string =~ /^[a-z0-9\ \.\-\/\']*$/i); # [CFChars]
|
446
|
+
};
|
447
|
+
|
448
|
+
|
449
|
+
#
|
450
|
+
# Function: CFCharNames
|
451
|
+
#
|
452
|
+
# Returns a plain-english list of <CFChars> which can be embedded in a sentence. For example, "You can only use
|
453
|
+
# [CFCharsList()] in the name.
|
454
|
+
#
|
455
|
+
sub CFCharNames
|
456
|
+
{
|
457
|
+
# [CFChars]
|
458
|
+
return 'letters, numbers, spaces, periods, dashes, slashes, and apostrophes';
|
459
|
+
};
|
460
|
+
|
461
|
+
|
462
|
+
#
|
463
|
+
# Function: Obscure
|
464
|
+
#
|
465
|
+
# Obscures the passed text so that it is not user editable and returns it. The encoding method is not secure; it is just designed
|
466
|
+
# to be fast and to discourage user editing.
|
467
|
+
#
|
468
|
+
sub Obscure #(text)
|
469
|
+
{
|
470
|
+
my ($self, $text) = @_;
|
471
|
+
|
472
|
+
# ` is specifically chosen to encode to space because of its rarity. We don't want a trailing one to get cut off before decoding.
|
473
|
+
$text =~ tr{a-zA-Z0-9\ \\\/\.\:\_\-\`}
|
474
|
+
{pY9fGc\`R8lAoE\\uIdH6tN\/7sQjKx0B5mW\.vZ41PyFg\:CrLaO\_eUi2DhT\-nSqJkXb3MwVz\ };
|
475
|
+
|
476
|
+
return $text;
|
477
|
+
};
|
478
|
+
|
479
|
+
|
480
|
+
#
|
481
|
+
# Function: Unobscure
|
482
|
+
#
|
483
|
+
# Restores text encoded with <Obscure()> and returns it.
|
484
|
+
#
|
485
|
+
sub Unobscure #(text)
|
486
|
+
{
|
487
|
+
my ($self, $text) = @_;
|
488
|
+
|
489
|
+
$text =~ tr{pY9fGc\`R8lAoE\\uIdH6tN\/7sQjKx0B5mW\.vZ41PyFg\:CrLaO\_eUi2DhT\-nSqJkXb3MwVz\ }
|
490
|
+
{a-zA-Z0-9\ \\\/\.\:\_\-\`};
|
491
|
+
|
492
|
+
return $text;
|
493
|
+
};
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
1;
|