Module: RDoc::Generator::LaTeX_Markup
- Defined in:
- lib/rdoc/generator/latex_markup.rb
Overview
Mixin module mixed into RDoc::CodeObject subclasses in order to overwrite RDoc’s standard RDoc::Generator::Markup mixin module that forces RDoc to HTML output. This module forces RDoc to LaTeX output ;-).
Note that just mixing this into RDoc::CodeObject isn’t enough as the RDoc::Generator::Markup module is mixed into the subclasses and would therefore take precedence during method lookup.
Constant Summary collapse
- LABEL_ESCAPE =
Special escapes to be used inside the hyperref labels (hyperref doesn’t accept the normal escapes correctly or not at all (in case of _ -> _). A hash of form:
"char" => "escape"
{ "#" => ":INST:", "%" => ":perc:", "^" => ":xor:", "&" => ":amp:", "_" => ":und:", "~" => ":tilde:", "[" => ":rbracket:", "]" => ":lbracket:", "=" => ":equal:" }.freeze
Instance Method Summary collapse
-
#current_heading_level ⇒ Object
Heading depth the formatter is currently in.
-
#formatter ⇒ Object
Instanciates the LaTeX formatter if it is necessary and stores it in an instance variable @formatter.
-
#latex_label ⇒ Object
Create an unique label for this CodeObject.
-
#latexized(symbol, *args, &block) ⇒ Object
Calls a method of this CodeObject and passes the return value to RDoc::Markup::ToLaTeX#escape.
Instance Method Details
#current_heading_level ⇒ Object
Heading depth the formatter is currently in. This is added to any heading request the processed markup mades in order to ensure that the correct LaTeX heading order is always preserved. For example, if the user orders a level 2 heading in a file (the README for instance), he gets a larger heading as if he had ordered a level 2 heading inside a method description.
104 105 106 107 108 109 110 111 112 |
# File 'lib/rdoc/generator/latex_markup.rb', line 104 def current_heading_level case self when RDoc::TopLevel then 0 when RDoc::ClassModule then 1 #Never-ever use level 1 headings apart from TopLevels... when RDoc::MethodAttr, RDoc::Alias, RDoc::Constant, RDoc::Include then 3 else 0 end end |
#formatter ⇒ Object
Instanciates the LaTeX formatter if it is necessary and stores it in an instance variable @formatter. This method is automatically called by RDoc to obtain the formatter this generator wants to use.
Return value
Returns the newly instanciated or already stored LaTeX formatter.
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/rdoc/generator/latex_markup.rb', line 87 def formatter return @formatter if defined?(@formatter) @formatter = RDoc::Markup::ToLaTeX_Crossref.new(self.kind_of?(RDoc::Context) ? self : @parent, #Thanks to RDoc for this current_heading_level, RDoc::RDoc.current..inputencoding, RDoc::RDoc.current..show_hash, RDoc::RDoc.current..show_pages, RDoc::RDoc.current..hyperlink_all) end |
#latex_label ⇒ Object
Create an unique label for this CodeObject.
Return value
A string (hopefully) uniquely identifying this CodeObject. Intended for use as the reference in a \href
command.
Raises
- PapyrusError
-
self
isn’t a CodeObject (→ Context::Section).
53 54 55 56 57 58 59 60 61 |
# File 'lib/rdoc/generator/latex_markup.rb', line 53 def latex_label case self when RDoc::Context then "class-module-#{label_escape(full_name)}" when RDoc::MethodAttr then "method-attr-#{label_escape(full_name)}" when RDoc::Constant then "const-#{label_escape(parent.full_name)}::#{label_escape(name)}" else raise(RDoc::Generator::Papyrus::PapyrusError, "Unrecognized token: #{self.inspect}!") end end |
#latexized(symbol, *args, &block) ⇒ Object
Calls a method of this CodeObject and passes the return value to RDoc::Markup::ToLaTeX#escape.
Parameter
- symbol
-
The symbol of the method (or attribute getter, same in Ruby) to call.
- *args
-
Any arguments to pass to the method.
- &block
-
A block to pass to the method.
Return value
A string from which everything LaTeXnically dangerous has been escaped.
Raises
- NoMethodError
-
You passed a
symbol
of an undefined method.
73 74 75 76 77 78 79 |
# File 'lib/rdoc/generator/latex_markup.rb', line 73 def latexized(symbol, *args, &block) if respond_to?(symbol) formatter.escape(send(symbol, *args, &block).to_s) #formatter method defined below else raise(NoMethodError, "Requested call to unknown method #{self.class}##{symbol} to be latexized!") end end |