Class: RDoc::Generator::Markdown
- Inherits:
-
Object
- Object
- RDoc::Generator::Markdown
- Defined in:
- lib/rdoc/generator/markdown.rb
Overview
Generates Markdown output and a CSV search index from an RDoc store.
Defined Under Namespace
Modules: OptionsExtension
Constant Summary collapse
- MARKDOWN_UNKNOWN_TAGS =
Supported reverse_markdown unknown-tag modes.
%i[pass_through drop bypass raise]
- ROOT_PAGES =
Root source page basenames and their search-index types.
{ "readme" => "Readme", "guide" => "Readme", "changelog" => "Changelog", "history" => "Changelog" }
- ROOT_PAGE_EXTENSIONS =
Source page extensions eligible for root page classification.
%w[.rdoc .md .markdown]
- TEMPLATE_DIR =
Directory containing ERB templates.
File.(File.join(File.dirname(__FILE__), "..", "..", "templates"))
Instance Attribute Summary collapse
-
#base_dir ⇒ Pathname
readonly
Working directory captured when the generator is created.
-
#classes ⇒ Array<RDoc::Context>?
readonly
Classes and modules selected for output.
-
#pages ⇒ Array<RDoc::TopLevel>?
readonly
Text files selected for output.
-
#store ⇒ RDoc::Store
readonly
Source store for generated content.
Class Method Summary collapse
-
.root_page_type_for(source_path) ⇒ String?
Returns the configured search-index type for an eligible root text page path.
-
.setup_options(rdoc_options) ⇒ void
Registers markdown generator-specific RDoc options.
-
.validate_markdown_unknown_tags(value) ⇒ Symbol
Validates the configured reverse_markdown unknown-tag mode.
Instance Method Summary collapse
-
#class_dir ⇒ nil
(also: #file_dir)
Required by RDoc's generator interface; markdown output has no class subdirectory.
-
#generate ⇒ void
Writes class files, page files, and the search index.
-
#initialize(store, rdoc_options) ⇒ Markdown
constructor
Creates a generator for an RDoc store and options.
Constructor Details
#initialize(store, rdoc_options) ⇒ Markdown
Creates a generator for an RDoc store and options.
141 142 143 144 145 146 147 148 |
# File 'lib/rdoc/generator/markdown.rb', line 141 def initialize(store, ) @store = store @options = @markdown_unknown_tags = self.class.(.) @base_dir = Pathname.pwd @expanded_root = Pathname(@options.root.to_s). end |
Instance Attribute Details
#base_dir ⇒ Pathname (readonly)
Working directory captured when the generator is created.
116 117 118 |
# File 'lib/rdoc/generator/markdown.rb', line 116 def base_dir @base_dir end |
#classes ⇒ Array<RDoc::Context>? (readonly)
Classes and modules selected for output.
121 122 123 |
# File 'lib/rdoc/generator/markdown.rb', line 121 def classes @classes end |
#pages ⇒ Array<RDoc::TopLevel>? (readonly)
Text files selected for output.
126 127 128 |
# File 'lib/rdoc/generator/markdown.rb', line 126 def pages @pages end |
#store ⇒ RDoc::Store (readonly)
Source store for generated content.
111 112 113 |
# File 'lib/rdoc/generator/markdown.rb', line 111 def store @store end |
Class Method Details
.root_page_type_for(source_path) ⇒ String?
Returns the configured search-index type for an eligible root text page path.
37 38 39 40 41 42 |
# File 'lib/rdoc/generator/markdown.rb', line 37 def self.root_page_type_for(source_path) return unless File.dirname(source_path) == "." return unless ROOT_PAGE_EXTENSIONS.include?(File.extname(source_path)) ROOT_PAGES[File.basename(source_path, ".*").downcase] end |
.setup_options(rdoc_options) ⇒ void
This method returns an undefined value.
Registers markdown generator-specific RDoc options.
86 87 88 89 90 91 92 93 |
# File 'lib/rdoc/generator/markdown.rb', line 86 def self.() .option_parser.on( "--markdown-unknown-tags=MODE", "How to handle unknown HTML tags: #{MARKDOWN_UNKNOWN_TAGS.join(", ")}." ) do |value| . = value.to_sym end end |
.validate_markdown_unknown_tags(value) ⇒ Symbol
Validates the configured reverse_markdown unknown-tag mode.
100 101 102 103 104 105 106 |
# File 'lib/rdoc/generator/markdown.rb', line 100 def self.(value) return value if MARKDOWN_UNKNOWN_TAGS.include?(value) expected = MARKDOWN_UNKNOWN_TAGS.map { |mode| ":#{mode}" }.join(", ") raise OptionParser::InvalidArgument, "invalid markdown_unknown_tags: #{value.inspect} (expected one of: #{expected})" end |
Instance Method Details
#class_dir ⇒ nil Also known as: file_dir
Required by RDoc's generator interface; markdown output has no class subdirectory.
131 132 |
# File 'lib/rdoc/generator/markdown.rb', line 131 def class_dir end |
#generate ⇒ void
This method returns an undefined value.
Writes class files, page files, and the search index.
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/rdoc/generator/markdown.rb', line 153 def generate debug("Setting things up ") setup debug("Generate documentation in #{@output_dir}") emit_classfiles debug("Generate pages in #{@output_dir}") emit_pagefiles debug("Generate index file in #{@output_dir}") emit_csv_index end |