# # Gem::RDoc provides methods to generate RDoc and ri data for installed gems # upon gem installation. # # This file is automatically required by RubyGems 1.9 and newer. # # # RDoc produces documentation for Ruby source files by parsing the source and # extracting the definition for classes, modules, methods, includes and # requires. It associates these with optional documentation contained in an # immediately preceding comment block then renders the result using an output # formatter. # # For a simple introduction to writing or generating documentation using RDoc # see the README. # # ## Roadmap # # If you think you found a bug in RDoc see CONTRIBUTING@Bugs # # If you want to use RDoc to create documentation for your Ruby source files, # see RDoc::Markup and refer to `rdoc --help` for command line usage. # # If you want to set the default markup format see # RDoc::Markup@Supported+Formats # # If you want to store rdoc configuration in your gem (such as the default # markup format) see RDoc::Options@Saved+Options # # If you want to write documentation for Ruby files see RDoc::Parser::Ruby # # If you want to write documentation for extensions written in C see # RDoc::Parser::C # # If you want to generate documentation using `rake` see RDoc::Task. # # If you want to drive RDoc programmatically, see RDoc::RDoc. # # If you want to use the library to format text blocks into HTML or other # formats, look at RDoc::Markup. # # If you want to make an RDoc plugin such as a generator or directive handler # see RDoc::RDoc. # # If you want to write your own output generator see RDoc::Generator. # # If you want an overview of how RDoc works see CONTRIBUTING # # ## Credits # # RDoc is currently being maintained by Eric Hodel . # # Dave Thomas is the original author of RDoc. # # * The Ruby parser in rdoc/parse.rb is based heavily on the outstanding work # of Keiju ISHITSUKA of Nippon Rational Inc, who produced the Ruby parser # for irb and the rtags package. # module RDoc # # A parser is simple a class that subclasses RDoc::Parser and implements #scan # to fill in an RDoc::TopLevel with parsed data. # # The initialize method takes an RDoc::TopLevel to fill with parsed content, the # name of the file to be parsed, the content of the file, an RDoc::Options # object and an RDoc::Stats object to inform the user of parsed items. The scan # method is then called to parse the file and must return the RDoc::TopLevel # object. By calling super these items will be set for you. # # In order to be used by RDoc the parser needs to register the file extensions # it can parse. Use ::parse_files_matching to register extensions. # # require 'rdoc' # # class RDoc::Parser::Xyz < RDoc::Parser # parse_files_matching /\.xyz$/ # # def initialize top_level, file_name, content, options, stats # super # # # extra initialization if needed # end # # def scan # # parse file and fill in @top_level # end # end # class Parser # # Record which file types this parser can understand. # # It is ok to call this multiple times. # def self?.parse_files_matching: (Regexp path) -> void # # Creates a new Parser storing `top_level`, `file_name`, `content`, `options` # and `stats` in instance variables. In +@preprocess+ an # RDoc::Markup::PreProcess object is created which allows processing of # directives. # def initialize: (RDoc::TopLevel top_level, String filename, String content, Hash[untyped, untyped] options, RDoc::Stats stats) -> void def scan: () -> RDoc::TopLevel end # # Base class for the RDoc code tree. # # We contain the common stuff for contexts (which are containers) and other # elements (methods, attributes and so on) # # Here's the tree of the CodeObject subclasses: # # * RDoc::Context # * RDoc::TopLevel # * RDoc::ClassModule # * RDoc::AnonClass (never used so far) # * RDoc::NormalClass # * RDoc::NormalModule # * RDoc::SingleClass # # # * RDoc::MethodAttr # * RDoc::Attr # * RDoc::AnyMethod # * RDoc::GhostMethod # * RDoc::MetaMethod # # # * RDoc::Alias # * RDoc::Constant # * RDoc::Mixin # * RDoc::Require # * RDoc::Include # class CodeObject # # Our comment # attr_reader comment: RDoc::Comment # # Creates a new CodeObject that will document itself and its children # def initialize: () -> void # # Replaces our comment with `comment`, unless it is empty. # def comment=: (RDoc::Comment | String) -> RDoc::Comment end # # A Context is something that can hold modules, classes, methods, attributes, # aliases, requires, and includes. Classes, modules, and files are all Contexts. # class Context < CodeObject include Comparable # # Types of methods # TYPES: ::Array["class" | "instance"] TOMDOC_TITLES: ::Array[nil | "Public" | "Internal" | "Deprecated"] type class_types = singleton(RDoc::NormalClass) | singleton(RDoc::SingleClass) # # Creates an unnamed empty context with public current visibility # def initialize: () -> void # # Adds `an_alias` that is automatically resolved # def add_alias: (RDoc::Alias an_alias) -> RDoc::Alias # # Adds `attribute` if not already there. If it is (as method(s) or attribute), # updates the comment if it was empty. # # The attribute is registered only if it defines a new method. For instance, # `attr_reader :foo` will not be registered if method `foo` exists, but # `attr_accessor :foo` will be registered if method `foo` exists, but `foo=` # does not. # def add_attribute: (RDoc::Attr attribute) -> RDoc::Attr # # Adds a class named `given_name` with `superclass`. # # Both `given_name` and `superclass` may contain '::', and are interpreted # relative to the `self` context. This allows handling correctly examples like # these: # class RDoc::Gauntlet < Gauntlet # module Mod # class Object # implies < ::Object # class SubObject < Object # this is _not_ ::Object # # Given `class Container::Item` RDoc assumes `Container` is a module unless it # later sees `class Container`. `add_class` automatically upgrades `given_name` # to a class in this case. # def add_class: (class_types class_type, ::String given_name, ?::String superclass) -> (RDoc::NormalClass | RDoc::SingleClass) # # Adds `constant` if not already there. If it is, updates the comment, value # and/or is_alias_for of the known constant if they were empty/nil. # def add_constant: (RDoc::Constant constant) -> RDoc::Constant # # Adds included module `include` which should be an RDoc::Include # def add_include: (RDoc::Include `include`) -> RDoc::Include # # Adds extension module `ext` which should be an RDoc::Extend # def add_extend: (RDoc::Extend ext) -> RDoc::Extend # # Adds `method` if not already there. If it is (as method or attribute), updates # the comment if it was empty. # def add_method: (RDoc::AnyMethod method) -> RDoc::AnyMethod # # Adds a module named `name`. If RDoc already knows `name` is a class then that # class is returned instead. See also #add_class. # def add_module: (singleton(RDoc::NormalModule) class_type, String name) -> RDoc::NormalModule # # Find a module with `name` using ruby's scoping rules # def find_module_named: (untyped name) -> (untyped | self) # # The full name for this context. This method is overridden by subclasses. # def full_name: () -> "(unknown)" def to_s: () -> ::String # # Return the TopLevel that owns us # def top_level: () -> RDoc::TopLevel end # # A TopLevel context is a representation of the contents of a single file # class TopLevel < Context MARSHAL_VERSION: 0 # # Creates a new TopLevel for the file at `absolute_name`. If documentation is # being generated outside the source dir `relative_name` is relative to the # source directory. # def initialize: (String absolute_name, ?String relative_name) -> void # # An RDoc::TopLevel is equal to another with the same relative_name # def ==: (untyped other) -> bool # # alias eql? == # # Adds `an_alias` to `Object` instead of `self`. # def add_alias: (RDoc::Alias an_alias) -> RDoc::Alias # # Adds `constant` to `Object` instead of `self`. # def add_constant: (RDoc::Constant constant) -> RDoc::Constant # # Adds `include` to `Object` instead of `self`. # def add_include: (RDoc::Include `include`) -> RDoc::Include # # Adds `method` to `Object` instead of `self`. # def add_method: (RDoc::AnyMethod method) -> RDoc::AnyMethod # # See RDoc::TopLevel::find_class_or_module # def find_class_or_module: (::String name) -> RDoc::Context # # Finds a module or class with `name` # def find_module_named: (String name) -> RDoc::Context # # Returns the relative name of this file # def full_name: () -> String def to_s: () -> ::String end # # A TokenStream is a list of tokens, gathered during the parse of some entity # (say a method). Entities populate these streams by being registered with the # lexer. Any class can collect tokens by including TokenStream. From the # outside, you use such an object by calling the start_collecting_tokens method, # followed by calls to add_token and pop_token. # module TokenStream # # Adds one `token` to the collected tokens # def add_token: (Hash[untyped, untyped] token) -> void # # Starts collecting tokens # def collect_tokens: () -> void # # alias start_collecting_tokens collect_tokens end # # A comment holds the text comment for a RDoc::CodeObject and provides a unified # way of cleaning it up and parsing it into an RDoc::Markup::Document. # # Each comment may have a different markup format set by #format=. By default # 'rdoc' is used. The :markup: directive tells RDoc which format to use. # # See RDoc::Markup@Other+directives for instructions on adding an alternate # format. # class Comment # # The format of this comment. Defaults to RDoc::Markup # attr_reader format: String # # The RDoc::TopLevel this comment was found in # attr_accessor location: String # # Creates a new comment with `text` that is found in the RDoc::TopLevel # `location`. # def initialize: (?String? text, ?RDoc::Context? location, ?String? language) -> void # # Sets the format of this comment and resets any parsed document # def format=: (String format) -> void end # # ClassModule is the base class for objects representing either a class or a # module. # class ClassModule < Context # # Creates a new ClassModule with `name` with optional `superclass` # # This is a constructor for subclasses, and must never be called directly. # def initialize: (String name, ?String superclass) -> void # # Adds `comment` to this ClassModule's list of comments at `location`. This # method is preferred over #comment= since it allows ri data to be updated # across multiple runs. # def add_comment: (RDoc::Comment comment, RDoc::Context location) -> void end # # A normal class, neither singleton nor anonymous # class NormalClass < ClassModule def initialize: (String name, ?String superclass) -> void end # # A singleton class # class SingleClass < ClassModule def initialize: (String name, ?String superclass) -> void end # # A normal module, like NormalClass # class NormalModule < ClassModule end # # Abstract class representing either a method or an attribute. # class MethodAttr < CodeObject include Comparable # # The method/attribute we're aliasing # attr_reader is_alias_for: MethodAttr? # # The call_seq or the param_seq with method name, if there is no call_seq. # attr_reader arglists: String # # Name of this method/attribute. # attr_accessor name: String # # public, protected, private # attr_accessor visibility: untyped # # Is this a singleton method/attribute? # attr_accessor singleton: bool # # Source file token stream # attr_reader text: String # # Different ways to call this method # attr_accessor call_seq: String # # Creates a new MethodAttr from token stream `text` and method or attribute name # `name`. # # Usually this is called by super from a subclass. # def initialize: (String text, String name) -> void # # Method/attribute name with class/instance indicator # def pretty_name: () -> ::String # # Type of method/attribute (class or instance) # def type: () -> ("class" | "instance") # # Path to this method for use with HTML generator output. # def path: () -> ::String def to_s: () -> ::String end # # AnyMethod is the base class for objects representing methods # class AnyMethod < MethodAttr include TokenStream # # Different ways to call this method # ---- # # Sets the different ways you can call this method. If an empty `call_seq` is # given nil is assumed. # # See also #param_seq # attr_accessor call_seq: ::String # # Parameters for this method # attr_accessor params: ::String attr_accessor line: Integer # # The call_seq or the param_seq with method name, if there is no call_seq. # # Use this for displaying a method's argument lists. # def arglists: () -> String? def callseq: () -> String? # # Creates a new AnyMethod with a token stream `text` and `name` # def initialize: (String? text, String name) -> void end # # An attribute created by #attr, #attr_reader, #attr_writer or #attr_accessor # class Attr < MethodAttr # # Is the attribute readable ('R'), writable ('W') or both ('RW')? # attr_accessor rw: "RW" | "R" | "W" # # Creates a new Attr with body `text`, `name`, read/write status `rw` and # `comment`. `singleton` marks this as a class attribute. # def initialize: (String? text, String name, String rw, RDoc::Comment? comment, ?bool `singleton`) -> void end # # A constant # class Constant < CodeObject # # Sets the module or class this is constant is an alias for. # attr_writer is_alias_for: String # # The constant's name # attr_accessor name: String # # The constant's value # attr_accessor value: String # # The constant's visibility # attr_accessor visibility: String # # Creates a new constant with `name`, `value` and `comment` # def initialize: (String name, String value, RDoc::Comment? comment) -> void end # # A Mixin adds features from a module into another context. RDoc::Include and # RDoc::Extend are both mixins. # class Mixin < CodeObject # # Name of included module # attr_accessor name: String # # Creates a new Mixin for `name` with `comment` # def initialize: (String name, RDoc::Comment? comment) -> void end # # A Module included in a class with #include # # RDoc::Include.new 'Enumerable', 'comment ...' # class Include < Mixin end # # A Module extension to a class with #extend # # RDoc::Extend.new 'Enumerable', 'comment ...' # class Extend < Mixin end # # Represent an alias, which is an old_name/new_name pair associated with a # particular context # class Alias < CodeObject # # Aliased method's name # attr_accessor name: String # # Aliasee method's name # attr_accessor old_name: String # # Creates a new Alias with a token stream of `text` that aliases `old_name` to # `new_name`, has `comment` and is a `singleton` context. # def initialize: (String? text, String name, String old_name, RDoc::Comment? comment, ?bool `singleton`) -> void end # # RDoc statistics collector which prints a summary and report of a project's # documentation totals. # class Stats end end