Module: RDoc::Generator::Markdown::CrossrefExtension
- Defined in:
- lib/rdoc/generator/markdown/crossref.rb
Overview
Prevents RDoc from linking to code objects omitted from Markdown output.
Instance Attribute Summary collapse
-
#markdown_cross_reference ⇒ Object
writeonly
Cross-reference resolver scoped to this formatter instance.
-
#markdown_output_object_ids ⇒ Object
writeonly
Object IDs emitted by the active Markdown generator.
Instance Method Summary collapse
-
#link(name, text, code = true, rdoc_ref: false) ⇒ String
Renders a cross-reference only when its owning object is emitted.
Instance Attribute Details
#markdown_cross_reference=(value) ⇒ Object (writeonly)
Cross-reference resolver scoped to this formatter instance.
6 7 8 |
# File 'lib/rdoc/generator/markdown/crossref.rb', line 6 def markdown_cross_reference=(value) @markdown_cross_reference = value end |
#markdown_output_object_ids=(value) ⇒ Object (writeonly)
Object IDs emitted by the active Markdown generator.
9 10 11 |
# File 'lib/rdoc/generator/markdown/crossref.rb', line 9 def markdown_output_object_ids=(value) @markdown_output_object_ids = value end |
Instance Method Details
#link(name, text, code = true, rdoc_ref: false) ⇒ String
Renders a cross-reference only when its owning object is emitted.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rdoc/generator/markdown/crossref.rb', line 19 def link(name, text, code = true, rdoc_ref: false) return super unless @markdown_cross_reference ref = @markdown_cross_reference.resolve(name) if name return super unless RDoc::CodeObject === ref context = ref context = context.parent until RDoc::ClassModule === context || RDoc::TopLevel === context return super if @markdown_output_object_ids.include?(context.object_id) return text if RDoc::TopLevel === ref || !code "<code>#{text}</code>" end |