webgen 1.0.0.beta3 → 1.0.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.
- checksums.yaml +7 -0
- data/COPYING +23 -1
- data/Rakefile +16 -77
- data/VERSION +1 -1
- data/bin/webgen +0 -0
- data/data/webgen/basic_website_template/ext/init.rb +3 -1
- data/data/webgen/basic_website_template/src/.gitignore +0 -0
- data/data/webgen/basic_website_template/webgen.config +1 -1
- data/data/webgen/bundle_template_files/info.yaml.erb +14 -2
- data/data/webgen/passive_sources/default.metainfo +10 -0
- data/data/webgen/passive_sources/templates/api.template +16 -2
- data/data/webgen/passive_sources/templates/feed.template +5 -5
- data/data/webgen/passive_sources/templates/sitemap.template +1 -1
- data/data/webgen/passive_sources/templates/tag.template +8 -4
- data/lib/webgen/blackboard.rb +21 -5
- data/lib/webgen/bundle/built-in-show-changes/info.yaml +17 -0
- data/lib/webgen/bundle/built-in-show-changes/init.rb +4 -5
- data/lib/webgen/bundle/built-in/info.yaml +1064 -0
- data/lib/webgen/bundle/built-in/init.rb +103 -136
- data/lib/webgen/bundle_loader.rb +82 -9
- data/lib/webgen/cli.rb +12 -8
- data/lib/webgen/cli/commands/create.rb +27 -0
- data/lib/webgen/cli/{create_bundle_command.rb → commands/create_bundle.rb} +2 -2
- data/lib/webgen/cli/{create_command.rb → commands/create_website.rb} +2 -2
- data/lib/webgen/cli/commands/generate.rb +66 -0
- data/lib/webgen/cli/{install_bundle_command.rb → commands/install.rb} +1 -1
- data/lib/webgen/cli/{show_command.rb → commands/show.rb} +6 -4
- data/lib/webgen/cli/{list_bundle_command.rb → commands/show_bundles.rb} +12 -15
- data/lib/webgen/cli/{show_config_command.rb → commands/show_config.rb} +34 -6
- data/lib/webgen/cli/{show_dependencies_command.rb → commands/show_dependencies.rb} +0 -0
- data/lib/webgen/cli/{show_extensions_command.rb → commands/show_extensions.rb} +1 -13
- data/lib/webgen/cli/{show_tree_command.rb → commands/show_tree.rb} +3 -0
- data/lib/webgen/cli/utils.rb +1 -1
- data/lib/webgen/configuration.rb +9 -11
- data/lib/webgen/content_processor/html_head.rb +3 -4
- data/lib/webgen/content_processor/rainpress.rb +21 -0
- data/lib/webgen/content_processor/sass.rb +8 -8
- data/lib/webgen/content_processor/tikz.rb +59 -16
- data/lib/webgen/item_tracker.rb +33 -12
- data/lib/webgen/item_tracker/missing_node.rb +5 -5
- data/lib/webgen/item_tracker/template_chain.rb +52 -0
- data/lib/webgen/misc/dummy_index.rb +78 -0
- data/lib/webgen/node.rb +1 -1
- data/lib/webgen/node_finder.rb +86 -141
- data/lib/webgen/page.rb +5 -5
- data/lib/webgen/path.rb +4 -1
- data/lib/webgen/path_handler.rb +25 -21
- data/lib/webgen/path_handler/api.rb +36 -3
- data/lib/webgen/path_handler/base.rb +20 -4
- data/lib/webgen/path_handler/feed.rb +6 -2
- data/lib/webgen/path_handler/meta_info.rb +4 -2
- data/lib/webgen/path_handler/page.rb +5 -7
- data/lib/webgen/path_handler/sitemap.rb +6 -1
- data/lib/webgen/path_handler/virtual.rb +6 -8
- data/lib/webgen/source/file_system.rb +2 -2
- data/lib/webgen/tag.rb +22 -18
- data/lib/webgen/tag/menu.rb +5 -5
- data/lib/webgen/test_helper.rb +18 -18
- data/lib/webgen/utils/external_command.rb +1 -1
- data/lib/webgen/utils/tag_parser.rb +1 -1
- data/lib/webgen/vendor/rainpress.rb +168 -0
- data/lib/webgen/version.rb +1 -1
- data/lib/webgen/website.rb +10 -10
- data/man/man1/webgen.1 +54 -23
- data/test/test_documentation.rb +27 -4
- data/test/webgen/cli/test_logger.rb +1 -1
- data/test/webgen/content_processor/test_blocks.rb +1 -1
- data/test/webgen/content_processor/test_builder.rb +3 -2
- data/test/webgen/content_processor/test_erb.rb +1 -1
- data/test/webgen/content_processor/test_erubis.rb +2 -2
- data/test/webgen/content_processor/test_fragments.rb +1 -1
- data/test/webgen/content_processor/test_haml.rb +2 -2
- data/test/webgen/content_processor/test_html_head.rb +5 -1
- data/test/webgen/content_processor/test_kramdown.rb +2 -2
- data/test/webgen/content_processor/test_maruku.rb +2 -2
- data/test/webgen/content_processor/test_r_discount.rb +2 -2
- data/test/webgen/content_processor/test_r_doc.rb +1 -1
- data/test/webgen/content_processor/test_rainpress.rb +19 -0
- data/test/webgen/content_processor/test_red_cloth.rb +2 -2
- data/test/webgen/content_processor/test_ruby.rb +1 -1
- data/test/webgen/content_processor/test_sass.rb +8 -6
- data/test/webgen/content_processor/test_scss.rb +3 -3
- data/test/webgen/content_processor/test_tags.rb +1 -1
- data/test/webgen/content_processor/test_tidy.rb +9 -1
- data/test/webgen/content_processor/test_tikz.rb +6 -3
- data/test/webgen/content_processor/test_xmllint.rb +9 -2
- data/test/webgen/destination/test_file_system.rb +4 -4
- data/test/webgen/item_tracker/test_file.rb +1 -1
- data/test/webgen/item_tracker/test_missing_node.rb +1 -1
- data/test/webgen/item_tracker/test_node_content.rb +1 -1
- data/test/webgen/item_tracker/test_node_meta_info.rb +1 -1
- data/test/webgen/item_tracker/test_nodes.rb +2 -4
- data/test/webgen/item_tracker/test_template_chain.rb +36 -0
- data/test/webgen/misc/test_dummy_index.rb +83 -0
- data/test/webgen/path_handler/test_api.rb +6 -46
- data/test/webgen/path_handler/test_base.rb +3 -2
- data/test/webgen/path_handler/test_copy.rb +1 -1
- data/test/webgen/path_handler/test_feed.rb +3 -4
- data/test/webgen/path_handler/test_meta_info.rb +1 -1
- data/test/webgen/path_handler/test_page.rb +1 -1
- data/test/webgen/path_handler/test_page_utils.rb +1 -1
- data/test/webgen/path_handler/test_sitemap.rb +3 -5
- data/test/webgen/path_handler/test_template.rb +1 -1
- data/test/webgen/path_handler/test_virtual.rb +1 -3
- data/test/webgen/source/test_file_system.rb +9 -4
- data/test/webgen/source/test_stacked.rb +1 -1
- data/test/webgen/source/test_tar_archive.rb +2 -2
- data/test/webgen/tag/test_breadcrumb_trail.rb +1 -1
- data/test/webgen/tag/test_coderay.rb +3 -2
- data/test/webgen/tag/test_date.rb +1 -1
- data/test/webgen/tag/test_execute_command.rb +1 -1
- data/test/webgen/tag/test_include_file.rb +1 -1
- data/test/webgen/tag/test_langbar.rb +1 -1
- data/test/webgen/tag/test_link.rb +1 -1
- data/test/webgen/tag/test_menu.rb +12 -30
- data/test/webgen/tag/test_meta_info.rb +1 -1
- data/test/webgen/tag/test_relocatable.rb +1 -1
- data/test/webgen/tag/test_tikz.rb +3 -2
- data/test/webgen/task/test_create_website.rb +2 -2
- data/test/webgen/test_blackboard.rb +11 -3
- data/test/webgen/test_bundle_loader.rb +26 -9
- data/test/webgen/test_cache.rb +1 -1
- data/test/webgen/test_cli.rb +2 -2
- data/test/webgen/test_configuration.rb +8 -9
- data/test/webgen/test_content_processor.rb +1 -1
- data/test/webgen/test_context.rb +1 -1
- data/test/webgen/test_core_ext.rb +1 -1
- data/test/webgen/test_destination.rb +1 -1
- data/test/webgen/test_error.rb +5 -5
- data/test/webgen/test_extension_manager.rb +1 -1
- data/test/webgen/test_item_tracker.rb +26 -5
- data/test/webgen/test_languages.rb +1 -1
- data/test/webgen/test_logger.rb +1 -1
- data/test/webgen/test_node.rb +1 -1
- data/test/webgen/test_node_finder.rb +2 -2
- data/test/webgen/test_page.rb +5 -5
- data/test/webgen/test_path.rb +8 -8
- data/test/webgen/test_rake_task.rb +1 -1
- data/test/webgen/test_source.rb +1 -1
- data/test/webgen/test_tag.rb +16 -24
- data/test/webgen/test_task.rb +1 -1
- data/test/webgen/test_tree.rb +1 -1
- data/test/webgen/test_utils.rb +1 -1
- data/test/webgen/test_website.rb +1 -1
- data/test/webgen/utils/test_tag_parser.rb +1 -1
- metadata +85 -105
- data/lib/webgen/cli/bundle_command.rb +0 -30
- data/lib/webgen/cli/generate_command.rb +0 -25
data/lib/webgen/cli.rb
CHANGED
|
@@ -6,10 +6,10 @@ require 'webgen/website'
|
|
|
6
6
|
require 'webgen/version'
|
|
7
7
|
require 'webgen/cli/logger'
|
|
8
8
|
require 'webgen/cli/utils'
|
|
9
|
-
require 'webgen/cli/
|
|
10
|
-
require 'webgen/cli/
|
|
11
|
-
require 'webgen/cli/
|
|
12
|
-
require 'webgen/cli/
|
|
9
|
+
require 'webgen/cli/commands/generate'
|
|
10
|
+
require 'webgen/cli/commands/show'
|
|
11
|
+
require 'webgen/cli/commands/create'
|
|
12
|
+
require 'webgen/cli/commands/install'
|
|
13
13
|
|
|
14
14
|
module Webgen
|
|
15
15
|
|
|
@@ -133,7 +133,7 @@ module Webgen
|
|
|
133
133
|
*Utils.format_option_desc("Specify a simple configuration option (key=value)")) do |v|
|
|
134
134
|
k, v = v.split('=')
|
|
135
135
|
begin
|
|
136
|
-
@config_options[k] = YAML.load(v)
|
|
136
|
+
@config_options[k.to_s] = YAML.load(v.to_s)
|
|
137
137
|
rescue YAML::SyntaxError
|
|
138
138
|
raise ConfigurationOptionError.new("Couldn't parse value for '#{k}': #{$!}")
|
|
139
139
|
end
|
|
@@ -148,12 +148,16 @@ module Webgen
|
|
|
148
148
|
end
|
|
149
149
|
self.add_command(Webgen::CLI::GenerateCommand.new, true)
|
|
150
150
|
self.add_command(Webgen::CLI::ShowCommand.new)
|
|
151
|
-
self.add_command(Webgen::CLI::BundleCommand.new)
|
|
152
151
|
self.add_command(Webgen::CLI::CreateCommand.new)
|
|
152
|
+
self.add_command(Webgen::CLI::InstallCommand.new)
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
# Utility method for getting the Webgen::Website object.
|
|
156
|
-
|
|
156
|
+
#
|
|
157
|
+
# Returns a new website object (not an already created one) if +force_new+ is set to +true+.
|
|
158
|
+
def website(force_new = false)
|
|
159
|
+
return @website if defined?(@website) && !force_new
|
|
160
|
+
|
|
157
161
|
@directory = ENV['WEBGEN_WEBSITE'] if @directory.nil? && !ENV['WEBGEN_WEBSITE'].to_s.empty?
|
|
158
162
|
if @directory.nil? && @do_search
|
|
159
163
|
dir = Dir.pwd
|
|
@@ -162,7 +166,7 @@ module Webgen
|
|
|
162
166
|
@directory = dir if !file_missing
|
|
163
167
|
end
|
|
164
168
|
@directory = Dir.pwd if @directory.nil?
|
|
165
|
-
@website
|
|
169
|
+
@website = Webgen::Website.new(@directory, Webgen::CLI::Logger.new) do |site, before_init|
|
|
166
170
|
if before_init
|
|
167
171
|
site.ext.cli = self
|
|
168
172
|
site.logger.level = @log_level
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require 'webgen/cli/utils'
|
|
4
|
+
require 'webgen/cli/commands/create_website'
|
|
5
|
+
require 'webgen/cli/commands/create_bundle'
|
|
6
|
+
|
|
7
|
+
module Webgen
|
|
8
|
+
module CLI
|
|
9
|
+
|
|
10
|
+
# The CLI command for creating various products, like a basic website or an extension bundle.
|
|
11
|
+
class CreateCommand < CmdParse::Command
|
|
12
|
+
|
|
13
|
+
def initialize # :nodoc:
|
|
14
|
+
super('create', true, true, false)
|
|
15
|
+
self.short_desc = 'Create some product'
|
|
16
|
+
self.description = Webgen::CLI::Utils.format_command_desc(<<DESC)
|
|
17
|
+
Groups various commands together that are used for creating products, like a
|
|
18
|
+
website or an extension bundle.
|
|
19
|
+
DESC
|
|
20
|
+
add_command(CreateWebsiteCommand.new)
|
|
21
|
+
add_command(CreateBundleCommand.new)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -11,7 +11,7 @@ module Webgen
|
|
|
11
11
|
class CreateBundleCommand < CmdParse::Command
|
|
12
12
|
|
|
13
13
|
def initialize # :nodoc:
|
|
14
|
-
super('
|
|
14
|
+
super('bundle', false, false, true)
|
|
15
15
|
self.short_desc = 'Create an extension bundle'
|
|
16
16
|
self.description = Utils.format_command_desc(<<DESC)
|
|
17
17
|
Creates a new extension bundle. This command can either create a local bundle in the
|
|
@@ -30,7 +30,7 @@ DESC
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def usage # :nodoc:
|
|
33
|
-
"Usage: webgen [global options] bundle
|
|
33
|
+
"Usage: webgen [global options] create bundle [options] BUNDLE_NAME [DIRECTORY]"
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def execute(args) # :nodoc:
|
|
@@ -7,10 +7,10 @@ module Webgen
|
|
|
7
7
|
module CLI
|
|
8
8
|
|
|
9
9
|
# The CLI command for creating a webgen website.
|
|
10
|
-
class
|
|
10
|
+
class CreateWebsiteCommand < CmdParse::Command
|
|
11
11
|
|
|
12
12
|
def initialize # :nodoc:
|
|
13
|
-
super('
|
|
13
|
+
super('website', false)
|
|
14
14
|
self.short_desc = 'Create a basic webgen website'
|
|
15
15
|
self.description = Utils.format_command_desc(<<DESC)
|
|
16
16
|
Creates a webgen website at the specified directory. If the --template
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
require 'webgen/cli/utils'
|
|
4
|
+
|
|
5
|
+
module Webgen
|
|
6
|
+
module CLI
|
|
7
|
+
|
|
8
|
+
# The CLI command for generating a webgen website.
|
|
9
|
+
class GenerateCommand < CmdParse::Command
|
|
10
|
+
|
|
11
|
+
def initialize # :nodoc:
|
|
12
|
+
super('generate', false, false, false)
|
|
13
|
+
self.short_desc = 'Generate the webgen website'
|
|
14
|
+
self.description = Webgen::CLI::Utils.format_command_desc(<<EOF)
|
|
15
|
+
This command is executed by default when no other command was specified.
|
|
16
|
+
EOF
|
|
17
|
+
self.options = CmdParse::OptionParserWrapper.new do |opts|
|
|
18
|
+
opts.separator "Options:"
|
|
19
|
+
opts.on('-a', '--auto [SEC]', Integer,
|
|
20
|
+
*Utils.format_option_desc("Auto-generate the website every SEC seconds (5=default, 0=off)")) do |val|
|
|
21
|
+
@auto_generate_secs = val || 5
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
@auto_generate_secs = 0
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def execute(args) # :nodoc:
|
|
28
|
+
if @auto_generate_secs <= 0
|
|
29
|
+
commandparser.website.execute_task(:generate_website)
|
|
30
|
+
else
|
|
31
|
+
auto_generate
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def auto_generate #:nodoc:
|
|
36
|
+
puts 'Starting auto-generate mode'
|
|
37
|
+
|
|
38
|
+
time = Time.now
|
|
39
|
+
abort = false
|
|
40
|
+
old_paths = []
|
|
41
|
+
dirs = "{" << commandparser.website.config['sources'].map do |mp, type, *args|
|
|
42
|
+
type == :file_system ? File.join(args[0], args[1] || '**/*') : nil
|
|
43
|
+
end.compact.join(',') << "}"
|
|
44
|
+
|
|
45
|
+
Signal.trap('INT') {abort = true}
|
|
46
|
+
|
|
47
|
+
while !abort
|
|
48
|
+
paths = Dir[dirs].sort
|
|
49
|
+
if old_paths != paths || paths.any? {|p| File.mtime(p) > time}
|
|
50
|
+
begin
|
|
51
|
+
commandparser.website(true).execute_task(:generate_website)
|
|
52
|
+
rescue Webgen::Error => e
|
|
53
|
+
puts e.message
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
time = Time.now
|
|
57
|
+
old_paths = paths
|
|
58
|
+
sleep @auto_generate_secs
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
private :auto_generate
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
2
|
|
|
3
3
|
require 'webgen/cli/utils'
|
|
4
|
-
require 'webgen/cli/
|
|
5
|
-
require 'webgen/cli/
|
|
6
|
-
require 'webgen/cli/
|
|
7
|
-
require 'webgen/cli/
|
|
4
|
+
require 'webgen/cli/commands/show_extensions'
|
|
5
|
+
require 'webgen/cli/commands/show_config'
|
|
6
|
+
require 'webgen/cli/commands/show_dependencies'
|
|
7
|
+
require 'webgen/cli/commands/show_tree'
|
|
8
|
+
require 'webgen/cli/commands/show_bundles'
|
|
8
9
|
|
|
9
10
|
module Webgen
|
|
10
11
|
module CLI
|
|
@@ -24,6 +25,7 @@ DESC
|
|
|
24
25
|
add_command(ShowExtensionsCommand.new)
|
|
25
26
|
add_command(ShowDependenciesCommand.new)
|
|
26
27
|
add_command(ShowTreeCommand.new)
|
|
28
|
+
add_command(ShowBundlesCommand.new)
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
end
|
|
@@ -5,24 +5,24 @@ require 'webgen/cli/utils'
|
|
|
5
5
|
module Webgen
|
|
6
6
|
module CLI
|
|
7
7
|
|
|
8
|
-
# The CLI command for
|
|
9
|
-
class
|
|
8
|
+
# The CLI command for showing extension bundles.
|
|
9
|
+
class ShowBundlesCommand < CmdParse::Command
|
|
10
10
|
|
|
11
11
|
def initialize # :nodoc:
|
|
12
|
-
super('
|
|
13
|
-
self.short_desc = '
|
|
12
|
+
super('bundles', false, false, true)
|
|
13
|
+
self.short_desc = 'Show extension bundles'
|
|
14
14
|
self.description = Utils.format_command_desc(<<DESC)
|
|
15
|
-
|
|
15
|
+
Shows all loaded, available and installable bundles.
|
|
16
16
|
|
|
17
|
-
Loaded bundles are already used by the website,
|
|
18
|
-
not used and
|
|
17
|
+
Loaded bundles are already used by the website, available ones are installed but
|
|
18
|
+
not used and installable bundles can be installed if needed.
|
|
19
19
|
|
|
20
20
|
Hint: The global verbosity option enables additional output.
|
|
21
21
|
DESC
|
|
22
22
|
self.options = CmdParse::OptionParserWrapper.new do |opts|
|
|
23
23
|
opts.separator "Options:"
|
|
24
24
|
opts.on("-r", "--[no-]remote",
|
|
25
|
-
*Utils.format_option_desc("Use remote server for listing
|
|
25
|
+
*Utils.format_option_desc("Use remote server for listing installable bundles")) do |remote|
|
|
26
26
|
@remote = remote
|
|
27
27
|
end
|
|
28
28
|
end
|
|
@@ -30,10 +30,7 @@ DESC
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def execute(args) # :nodoc:
|
|
33
|
-
bundles =
|
|
34
|
-
commandparser.website.ext.bundles.each do |bundle, info_file|
|
|
35
|
-
bundles.update(bundle => (info_file ? YAML.load(File.read(info_file)) : {}))
|
|
36
|
-
end
|
|
33
|
+
bundles = commandparser.website.ext.bundle_infos.bundles.dup
|
|
37
34
|
bundles.each {|n,d| d[:state] = :loaded}
|
|
38
35
|
|
|
39
36
|
populate_hash = lambda do |file|
|
|
@@ -62,9 +59,9 @@ DESC
|
|
|
62
59
|
end
|
|
63
60
|
|
|
64
61
|
if @remote
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
bundle_name =
|
|
62
|
+
Gem::SpecFetcher.fetcher.detect(:latest) do |name_tuple|
|
|
63
|
+
next unless name_tuple.name =~ /webgen-(.*)-bundle/
|
|
64
|
+
bundle_name = $1
|
|
68
65
|
if !bundles.has_key?(bundle_name)
|
|
69
66
|
bundles[bundle_name] = {:state => :installable, :gem => spec.first}
|
|
70
67
|
end
|
|
@@ -15,12 +15,11 @@ module Webgen
|
|
|
15
15
|
Shows all available configuration options. The option name and default value as
|
|
16
16
|
well as the currently used value are displayed.
|
|
17
17
|
|
|
18
|
-
If the global verbosity option is set, option descriptions are additionally
|
|
19
|
-
displayed.
|
|
20
|
-
|
|
21
18
|
If an argument is given, only those options that have the argument in their name
|
|
22
19
|
are displayed.
|
|
23
20
|
|
|
21
|
+
The global verbosity flag enables all optional display parts.
|
|
22
|
+
|
|
24
23
|
Hint: A debug message will appear at the top of the output if this command is run
|
|
25
24
|
in the context of a website, there are unknown configuration options in the
|
|
26
25
|
configuration file and the log level is set to debug.
|
|
@@ -31,28 +30,57 @@ DESC
|
|
|
31
30
|
*Utils.format_option_desc("Show modified configuration options only")) do |v|
|
|
32
31
|
@modified = true
|
|
33
32
|
end
|
|
33
|
+
opts.on("-d", "--[no-]descriptions",
|
|
34
|
+
*Utils.format_option_desc("Show descriptions")) do |d|
|
|
35
|
+
@show_description = d
|
|
36
|
+
end
|
|
37
|
+
opts.on("-s", "--[no-]syntax",
|
|
38
|
+
*Utils.format_option_desc("Show the syntax")) do |s|
|
|
39
|
+
@show_syntax = s
|
|
40
|
+
end
|
|
41
|
+
opts.on("-e", "--[no-]example",
|
|
42
|
+
*Utils.format_option_desc("Show usage examples")) do |e|
|
|
43
|
+
@show_examples = e
|
|
44
|
+
end
|
|
34
45
|
end
|
|
35
46
|
@modified = false
|
|
47
|
+
@show_description = false
|
|
48
|
+
@show_syntax = false
|
|
49
|
+
@show_examples = false
|
|
36
50
|
end
|
|
37
51
|
|
|
38
52
|
def execute(args) # :nodoc:
|
|
53
|
+
@show_description = @show_syntax = @show_examples = true if commandparser.verbose
|
|
54
|
+
|
|
39
55
|
config = commandparser.website.config
|
|
56
|
+
descriptions = commandparser.website.ext.bundle_infos.options
|
|
40
57
|
selector = args.first.to_s
|
|
41
58
|
config.options.select do |n, d|
|
|
42
59
|
n.include?(selector) && (!@modified || config[n] != d.default)
|
|
43
60
|
end.sort.each do |name, data|
|
|
44
|
-
format_config_option(name, data, config[name])
|
|
61
|
+
format_config_option(name, data, config[name], descriptions[name])
|
|
45
62
|
end
|
|
46
63
|
end
|
|
47
64
|
|
|
48
|
-
def format_config_option(name, data, cur_val)
|
|
65
|
+
def format_config_option(name, data, cur_val, meta_info)
|
|
49
66
|
print("#{Utils.light(Utils.blue(name))}: ")
|
|
50
67
|
if cur_val != data.default
|
|
51
68
|
puts(Utils.green(cur_val.to_s) + " (default: #{data.default})")
|
|
52
69
|
else
|
|
53
70
|
puts(cur_val.inspect)
|
|
54
71
|
end
|
|
55
|
-
|
|
72
|
+
|
|
73
|
+
puts(Utils.format(meta_info['summary'], 78, 2, true).join("\n") + "\n\n") if @show_description
|
|
74
|
+
if @show_syntax
|
|
75
|
+
puts(Utils.format("Syntax:", 78, 2, true).join("\n"))
|
|
76
|
+
puts(Utils.format(meta_info['syntax'], 78, 4, true).join("\n") + "\n\n")
|
|
77
|
+
end
|
|
78
|
+
if @show_examples
|
|
79
|
+
meta_info['example'].each do |n,v|
|
|
80
|
+
puts(Utils.format("Example for usage in #{n}:", 78, 2, true).join("\n"))
|
|
81
|
+
puts(Utils.format(v, 78, 4, true).join("\n") + "\n\n")
|
|
82
|
+
end
|
|
83
|
+
end
|
|
56
84
|
end
|
|
57
85
|
private :format_config_option
|
|
58
86
|
|
|
File without changes
|
|
@@ -31,20 +31,8 @@ DESC
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def execute(args) # :nodoc:
|
|
34
|
-
exts = {}
|
|
35
|
-
commandparser.website.ext.bundles.each do |bundle, info_file|
|
|
36
|
-
next if info_file.nil? || (@bundle && @bundle != bundle)
|
|
37
|
-
infos = YAML.load(File.read(info_file))
|
|
38
|
-
next unless infos['extensions']
|
|
39
|
-
infos['extensions'].each do |n, d|
|
|
40
|
-
d['bundle'] = bundle
|
|
41
|
-
d['author'] ||= infos['author']
|
|
42
|
-
end
|
|
43
|
-
exts.update(infos['extensions'])
|
|
44
|
-
end
|
|
45
|
-
|
|
46
34
|
selector = args.first.to_s
|
|
47
|
-
|
|
35
|
+
commandparser.website.ext.bundle_infos.extensions.select {|n, d| n.include?(selector)}.sort.each do |name, data|
|
|
48
36
|
format_extension_info(name, data, !selector.empty?)
|
|
49
37
|
end
|
|
50
38
|
end
|
|
@@ -20,6 +20,9 @@ This command can be used before or after the website has been generated. Note,
|
|
|
20
20
|
however, that nodes that are created during generation like fragment nodes can
|
|
21
21
|
only be shown if the website has been generated.
|
|
22
22
|
|
|
23
|
+
Due to the way webgen works this command may take some time before actually
|
|
24
|
+
showing the tree because it has to be built first.
|
|
25
|
+
|
|
23
26
|
If an argument is given, only those nodes that have the argument in their LCN
|
|
24
27
|
are displayed.
|
|
25
28
|
|
data/lib/webgen/cli/utils.rb
CHANGED
|
@@ -10,7 +10,7 @@ module Webgen
|
|
|
10
10
|
module Utils
|
|
11
11
|
|
|
12
12
|
class << self; attr_accessor :use_colors; end
|
|
13
|
-
@use_colors = $stdout.tty? && RbConfig::CONFIG['host_os'] !~ /mswin|mingw/
|
|
13
|
+
@use_colors = $stdout.tty? && (RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ || ENV['ANSICON'])
|
|
14
14
|
|
|
15
15
|
DEFAULT_WIDTH = 80
|
|
16
16
|
|
data/lib/webgen/configuration.rb
CHANGED
|
@@ -9,26 +9,26 @@ module Webgen
|
|
|
9
9
|
#
|
|
10
10
|
# Configuration options can be created by using the define_option method:
|
|
11
11
|
#
|
|
12
|
-
# config.define_option "my.new.option", 'default value'
|
|
12
|
+
# config.define_option "my.new.option", 'default value'
|
|
13
13
|
#
|
|
14
14
|
# and later accessed or set using the accessor methods #[] and #[]=. A validation block can also
|
|
15
15
|
# be specified when defining an option. This validation block is called when a new value should be
|
|
16
16
|
# set and it should return the (possibly changed) value to be set:
|
|
17
17
|
#
|
|
18
|
-
# config.define_option "my.new.option", 'default value'
|
|
18
|
+
# config.define_option "my.new.option", 'default value' do |val|
|
|
19
19
|
# raise "Option must be a string" unless val.kind_of?(String)
|
|
20
20
|
# val.upcase
|
|
21
21
|
# end
|
|
22
22
|
#
|
|
23
23
|
# **Note**: When a Configuration object is dumped (via Marshal), the option validator procs are
|
|
24
|
-
# not dumped and can therefore not be restored
|
|
24
|
+
# not dumped and can therefore not be restored!
|
|
25
25
|
class Configuration
|
|
26
26
|
|
|
27
27
|
# Raised by the Webgen::Configuration class.
|
|
28
28
|
class Error < Webgen::Error; end
|
|
29
29
|
|
|
30
30
|
# Struct class for storing a configuration option.
|
|
31
|
-
Option = Struct.new(:default, :
|
|
31
|
+
Option = Struct.new(:default, :validator) do
|
|
32
32
|
def dupped_default #:nodoc:
|
|
33
33
|
default.dup rescue default
|
|
34
34
|
end
|
|
@@ -38,12 +38,11 @@ module Webgen
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def marshal_dump #:nodoc:
|
|
41
|
-
|
|
41
|
+
self.default
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def marshal_load(data) #:nodoc:
|
|
45
|
-
self.default = data
|
|
46
|
-
self.description = data[1]
|
|
45
|
+
self.default = data
|
|
47
46
|
end
|
|
48
47
|
|
|
49
48
|
end
|
|
@@ -82,17 +81,16 @@ module Webgen
|
|
|
82
81
|
@options == other.options && @values == other.instance_variable_get(:@values)
|
|
83
82
|
end
|
|
84
83
|
|
|
85
|
-
# Define a new option +name+ with a default value of +default
|
|
84
|
+
# Define a new option +name+ with a default value of +default+.
|
|
86
85
|
#
|
|
87
86
|
# If a validation block is provided, it is called with the new value when one is set and should
|
|
88
87
|
# return a (possibly altered) value to be set.
|
|
89
|
-
def define_option(name, default,
|
|
88
|
+
def define_option(name, default, &validator)
|
|
90
89
|
if @options.has_key?(name)
|
|
91
90
|
raise ArgumentError, "Configuration option '#{name}' has already be defined"
|
|
92
91
|
else
|
|
93
92
|
@options[name] = Option.new
|
|
94
93
|
@options[name].default = default.freeze
|
|
95
|
-
@options[name].description = description.freeze
|
|
96
94
|
@options[name].validator = validator.freeze
|
|
97
95
|
@options[name].freeze
|
|
98
96
|
end
|
|
@@ -174,7 +172,7 @@ module Webgen
|
|
|
174
172
|
data = if String === filename || filename.respond_to?(:read)
|
|
175
173
|
begin
|
|
176
174
|
YAML::load(String === filename ? File.read(filename) : filename.read) || {}
|
|
177
|
-
rescue RuntimeError, ArgumentError, SyntaxError => e
|
|
175
|
+
rescue RuntimeError, ArgumentError, SyntaxError, YAML::SyntaxError => e
|
|
178
176
|
raise Error, "Problem parsing configuration data (it needs to contain a YAML hash): #{e.message}", e.backtrace
|
|
179
177
|
end
|
|
180
178
|
else
|