Commit Graph

547 Commits

Author SHA1 Message Date
Charlie Sharpsteen e56842bc1b Add handler for future parser functions
All Future Parser functions are documented using a standard YARD comment block.
This commit adds a new code object that watches for `create_function` and
generates a YARD `CodeObject::MethodObject` containing the docstring.
2014-08-06 14:56:37 -07:00
Charlie Sharpsteen 752b5e9d0f Register PuppetFunctions with handler method
Use the `register` method of YARD handler objects instead of calling
`YARD::Registry.register` as the latter does not seem to work properly.
2014-06-19 16:32:28 -07:00
Charlie Sharpsteen 918e3bc9cc Tag all functions with @api public
The Puppet Core uses a `.yardopts` file that hides all docstrings that do not
have an API tag. This patch is a hack that allows `puppet yardoc` to extract
documentation for parser functions shipped in the core.

FIXME: This isn't the right way to solve the problem. The right way to solve
the problem is to adjust the Puppet `.yardopts` file to a sane value.
2014-06-19 16:31:58 -07:00
Charlie Sharpsteen 71427fad17 Skip function list render if no functions defined
If a module does not define any functions, skip rendering the "Functions"
section in the "Puppet Plugins List".
2014-06-12 22:48:56 -07:00
Charlie Sharpsteen 1b8cc98118 Move parser functions into a PuppetNamespace
Seperate Puppet parser functions out into a PuppetNamespace so they are no
longer listed with the Ruby methods.
2014-06-12 21:21:11 -07:00
Charlie Sharpsteen 32d69848e1 Small fixes to the namespace_list template helper
The `namespace_list` helper is used to filter YARD objects in order to populate
search lists. The code was originally derived from the `class_list` helper.
This patch guards against calling `children` on objects that have no children
and removes a recursive call to the old `class_list` method.
2014-06-12 21:15:50 -07:00
Charlie Sharpsteen 0307f0f5e9 Add new PuppetNamespaceObject class
This class is functionally equivalent to the ModuleObject class that YARD uses
for Ruby code. Using a new class allows us to gather YARD objects related to
Puppet and separate them from the Ruby bits.
2014-06-12 21:12:37 -07:00
Charlie Sharpsteen 243d6889d5 Monkeypatch a fix into YARD::Logger#show_progress
This method has an inverted conditional which means the progress bar still
animates when `--debug` is passed. Not having an easy way to switch the
animation off is a real bummer as it completely hoses the Pry REPL.

Ref. lsegal/yard#783
2014-06-11 23:48:39 -07:00
Charlie Sharpsteen 47d0cbe356 Exclude YARD templates directory from yard doc
The templates directory is full of stuff that `yard doc` can't process. This
causes a bunch of ugly warnings to flash across the screen.
2014-06-10 20:38:01 -07:00
Charlie Sharpsteen 6e1e9b3e24 Require Puppet >= 3.6.0
Mostly due to breaking changes in how the `puppet module list` Face works.
2014-06-09 21:20:56 -07:00
Charlie Sharpsteen c1217912dd Add custom YARD handler for parser functions
This handler triggers on all occurrences of `newfunction` and parses the
parameters passed to that method in order to generate documentation. The
implementation is a good experiment in extracting documentation without
evaluating Ruby code. However, the generality of this approach may ultimately
be doomed by the use of metaprogramming in custom Types and Providers.
2014-06-05 21:40:17 -07:00
Charlie Sharpsteen 9d99018952 Separate Puppet namespaces from Ruby namespaces
The default YARD template lumps anything that inherits from `NamespaceObject`
into the "Classes" list in HTML output. This patch alters the list generation
logic so that Namespaces parsed from manifests are listed in a separate
"Puppet Manifests" list.
2014-06-02 21:57:07 -07:00
Charlie Sharpsteen cb45a80928 Parse module lib directories along with manifests
The `puppet yardoc` face now parses any files matching `lib/**/*.rb` when
operating on modules.
2014-06-02 21:57:03 -07:00
Charlie Sharpsteen fd3a08bfc2 Map Puppet debugging flags to YARD options
This patch configures YARD to run in debug mode if Puppet flags such as
`--debug` or `--trace` are used.
2014-06-02 19:40:00 -07:00
Charlie Sharpsteen 84f31a8074 Handle cases where the parser returns nil
The Future Parser will return nil if a manifest file contains no statements
(I.E. it is empty or full of comments). Handle these cases and ensure the
`enumerate` method of the YARD parser always returns an Array.
2014-06-02 19:04:19 -07:00
Charlie Sharpsteen afb053c03b Add a server action to the yardoc face
This commit adds the `puppet yardoc server` action which is designed to
mimic `yard server --gems`. This action generates YARD indicies by invoking
`puppet yardoc modules` and then configures `YARD::CLI::Server` to serve the
resulting documentation.
2014-06-01 18:07:52 -07:00
Charlie Sharpsteen e2a9e40f01 Add a modules action to the yardoc face
This commit adds the `puppet yardoc modules` action which is designed to
process Puppet Modules in the same way `yard gems` processes Ruby Gems. This
action walks the list of modules generated by `puppet module list` and
generates a YARD index (.yardoc directory) in each module root. This index
contains all the data required to generate documentation using other YARD
tools.
2014-06-01 18:03:21 -07:00
Charlie Sharpsteen a71c53f3d5 Add DefinedTypeObject#inheritance_tree
The `YARD::Registry#resolve` method assumes all subclasses of `NamespaceObject`
respond to `inheritance_tree`.

Ref commit d6a4791 for a similar case with `HostClassObject`.
2014-06-01 18:03:20 -07:00
Charlie Sharpsteen 6480bd3a41 Revert "Clobber YARD namespace proxies"
This reverts commit a051319b34.

Added a FIXME note to `defined_type_object.rb` that explains why this patch was
originally created, why it was reverted and what unresolved issues remain.
2014-06-01 18:03:20 -07:00
Charlie Sharpsteen 07f9a800c7 Remove dependency on puppetlabs-stdlib
At the moment, there is no Puppet code in this module so there is no need for a
stdlib dependency.
2014-06-01 11:43:59 -07:00
Charlie Sharpsteen 043fb34721 Add docstrings to yardoc face 2014-05-31 23:24:27 -07:00
Charlie Sharpsteen 353b48bb1a Add README.md 2014-05-30 12:23:10 -07:00
Charlie Sharpsteen d5d977eced Add feature check for backports under Ruby 1.8.7 2014-05-30 09:59:55 -07:00
Charlie Sharpsteen 9cd4fd14a9 Extend doc generation to defined types
Puppet Yardoc now generates documentation for defined types in addition to host
classes. The actual change was fairly small, however this patch is quite large
as most of the host class bits were re-architected to inherit from defined
types. Host classes are basically the same as defined types with the addition
of inheritance. Pops also models Host Class using a similar inheritance
relationship.
2014-05-30 09:28:25 -07:00
Charlie Sharpsteen d0d943436e Add parameter summary to hostclass html docs
Format cribbed from YARD method and attribute summary blocks. Still some work
to do, but initial results don't look that bad.
2014-05-30 09:08:20 -07:00
Charlie Sharpsteen 005a8521bd Extract class parameters from parser output
Re-worked the YARD transformer and handlers to attach parameters to the
resulting code objects. Some architectural debt was incurred in the interests
of producing a working prototype quickly.
2014-05-28 23:53:12 -07:00
Charlie Sharpsteen e98761100d Fix plugin loading from YARD
This patch fixes an error related to `Puppet::Util` being missing when YARD
loads `puppetx/yardoc/yard/plugin`.
2014-05-28 00:07:15 -07:00
Charlie Sharpsteen d6a4791c30 Fix signature of HostClassObject#inheritance_tree
The `YARD::Registry` expects all subclasses of `NamespaceObject` to accept one
argument when `inheritance_tree` is called.
2014-05-27 20:52:59 -07:00
Charlie Sharpsteen d226d08ddb List subclasses for each host class
Basically a straight port of the logic from the YARD template for Ruby classes.
2014-05-27 19:45:02 -07:00
Charlie Sharpsteen 787fca8ebc Implement inheritance tree for host classes
Documentation pages for host classes now show the full inheritance tree instead
of just the immediate parent.
2014-05-27 19:34:12 -07:00
Charlie Sharpsteen d8bc2f3dce Display inheritance relationships for host classes 2014-05-26 22:36:22 -07:00
Charlie Sharpsteen a051319b34 Clobber YARD namespace proxies
When creating an object, YARD will split the object name using `::` and
recursively create proxy namespaces for each component. Unfortunately this
process is optimized for Ruby and somewhat mangles Puppet code as Puppet class
names are not capitalized.

For now, dispense with this behavior by implementing `HostClassObject.new`.
2014-05-26 17:55:43 -07:00
Charlie Sharpsteen 1b275a4926 Re-work yardoc options
The `puppet yardoc` command now consumes an optional list of manifest files to
document. If no files are passed, a default glob of `manifests/**/*.pp` will be
used.
2014-05-26 12:02:59 -07:00
Charlie Sharpsteen e3d2602cba Move Puppet classes into a custom namespace
Instead of documenting Puppet classes using `ClassObject`, use a custom
subclass of `NamespaceObject`. This is done because Puppet classes are not Ruby
classes and will have components that don't fit into the model offered by
`ClassObject`.

This commit also adds a couple of monkey patches to integrate the new
`:hostclass` into YARD tooling and the beginnings of some custom templating.
2014-05-25 22:59:46 -07:00
Charlie Sharpsteen 35e67f1187 Delegate processing to YARD::CLI::Yardoc
Loading `Puppetx::Yardoc::YARD::Plugin` registers the subsystems for Puppet
documentation with YARD. At this point, execution can be handed off to the
`YARD::CLI::Yardoc` tool.
2014-05-25 19:14:52 -07:00
Charlie Sharpsteen 5d5013b39d Add Bundler artifacts to .gitignore 2014-05-25 19:11:32 -07:00
Charlie Sharpsteen 0eb6ec1158 Support Ruby 1.8.7 using backports
The YARD plugin is currently architected using `require_relative` so that it
can be loaded outside of Puppet. Unfortunately, `require_relative` first
appeared in Ruby 1.9.1.

Achieve compatibility using the Backports gem.
2014-05-24 16:49:54 -07:00
Charlie Sharpsteen b4e2ed0e5c Re-work require statements
Use `require_relative` for all components under Puppetx. This makes it possible
to load `pupetx/yardoc/yard/plugin` outside of Puppet as a YARD plugin.

Also fix the `yardoc` face so that Puppetx bits are loaded _after_ feature
checks.
2014-05-24 16:46:37 -07:00
Charlie Sharpsteen 545a8a0c5e Add YARD plugin
A simple file that registers the parser and handlers with YARD.
2014-05-22 23:46:07 -07:00
Charlie Sharpsteen c56bc426be Add simple handlers
Add a base handler class and a handler that processes `HostClassDefinition`
instances.
2014-05-22 23:45:08 -07:00
Charlie Sharpsteen 9ef57b594e Trim comment characters from docstrings
A very naive attempt. Simple removes any leading whitespace, the comment
character and then one space.
2014-05-22 23:42:10 -07:00
Charlie Sharpsteen 66af766dba Add YARDStatement class
The `YARDStatement` class is an adaptor that composes a `Pops::Model` instance
along with applicable `Pops::Adapter` and presents a familiar interface for
`YARD::Handler` objects to work with.
2014-05-22 22:44:15 -07:00
Charlie Sharpsteen c8d318b161 Re-architect around a YARD parser
Start building a YARD parser. Parsing and comment extraction has been moved out
of the yardoc face and into the new `Puppetx::Yardoc::YARD::PuppetParser`
class. The old `Commentor` class from the Util module has been renamed to
`Puppetx::Yardoc::Pops::YARDTransformer`.

`puppet yardoc` is still capable of extracting docstrings for node, class and
type definitions from a single manifest file.
2014-05-22 22:23:34 -07:00
Charlie Sharpsteen f53cbed1bb Add rudimentary comment extractor
With this patch, the `yardoc` face will parse a manifest file and then extract
any comments associated with each node, class and type definition.
2014-05-21 22:14:53 -07:00
Charlie Sharpsteen 3ad750d103 Add feature guards for necessary requirements
Add `Puppet.feature` guards for the `yard` and `rgen` libraries.
2014-05-19 22:24:03 -07:00
Charlie Sharpsteen 3d71143614 Add skeleton of yardoc face
Currently just reads in a path to a `.pp` file and runs it through a Pops
parser.
2014-05-16 10:57:24 -07:00
Charlie Sharpsteen a9408c792b Initial commit
Added skeleton from `puppet module generate` minus bits related to manifests.
2014-05-16 10:57:24 -07:00