Commit Graph

202 Commits

Author SHA1 Message Date
Ian Kronquist 798cd5b816 (PDOC-35) Add a directive for puppet parameters
* Print yard documentation statistics for providers
* Define a directive which takes a type and a name
2015-09-09 14:35:23 -07:00
Ian Kronquist 676364bd17 (PDOC-35) First pass at documenting providers
Adding a provider page and menu
* Add categories to html search bar
* Require provider handler and object classes
* Fetch provider code objects from registry
* Add function to generate the provider list
* Fetch providers from registry in monkey patches
* Add provider templates
* Add provider code object
* Add provider handler
* Add erb file to populate the provider list
* Don't emit type information for providers in html
* Add tests for provider handler

Refactor heredoc:
* Remove heredoc annotations
* Move heredoc functions into a heredoc helper
* Add heredoc helper class
2015-09-09 14:35:02 -07:00
Henrik Lindberg d6c8bc507c Merge pull request #50 from iankronquist/choke-yard-warnings
(PDOC-38) Prevent warnings from being issued twice
2015-09-07 05:28:34 -07:00
Henrik Lindberg eeeb89f565 Merge pull request #53 from iankronquist/fix-defined-function-crash
(PDOC-45) Puppet 4x functions handle unusual names
2015-09-07 05:25:16 -07:00
Ian Kronquist 11e016e81e (PDOC-38) Prevent warnings from being issued twice
Since we threw away all of Yard's warnings we are no longer checking that the
parameter names match for Ruby methods. Thus we need to override Yard's
method_details template with our own to trigger our warning function. However,
there's a catch. If this ruby method is in a Puppet 4x function, we don't want
our warning function to trigger because the user has already been warned. Look
in the registry to see if there is already a Puppet 4x function with the same
name registered.

Also, print errors to stderr instead of using log.warn.
2015-09-04 14:45:08 -07:00
Ian Kronquist 84a215d599 (PDOC-45) Puppet 4x functions handle unusual names
`lib/puppet/functions/defined.rb` has some unusual syntax:

	Puppet::Functions.create_function(:'defined', ....

It runs, so apparently this is legal.
2015-09-01 15:31:13 -07:00
Julien Pivotto 005a3112c9 (MAINT) Add a space between a parameter name type and its description
Before this commit:

    packages (Array[String])- A list of packages to be installed

With this commit:

    packages (Array[String]) - A list of packages to be installed
2015-08-31 12:27:28 +02:00
Ian Kronquist f052675088 (PDOC-38) Add parameter mismatch warnings for 4.x 2015-08-21 10:36:31 -07:00
Ian Kronquist fe2420bc01 (PDOC-38) Monkey patch Yard's logger
Redirect Yard command line warnings to a log file called `.yardwarns`.
Yard warnings may be irrelevant, spurious, or may not conform with our
styling and UX design. They are also printed on stdout by default.
2015-08-21 10:36:31 -07:00
Ian Kronquist bd8d159016 (PDOC-21) Fix duplicate warnings for hostclasses
Host classes inherit behavior from defined types. I didn't realize this when I
was first implementing this functionality.
2015-08-19 10:47:32 -07:00
Ian Kronquist badd019364 (PDOC-21) Only create HostClass parameters once
You can pass a block to the constructor of the hostclass. For some reason Yard
is yielding the block twice. Our code is not yielding the block because we only
use yield in one place which is unrelated. I don't think this is intended
behavior on yard's part, it certainly seems odd, but we can dodge the question
and not have to wait for an upstream patch by extracting the logic from the
block and running it after the object has been initialized.
2015-08-12 10:18:31 -07:00
Ian Kronquist f7165d6634 (maint) Don't print extraneous "true".
Suppress it by printing an empty string instead.
2015-08-04 15:34:13 -07:00
Ian Kronquist c7af917c35 (PDOC-21) Check mismatched types in defined types
Check that the types for defined types match those specified in the
documentation. This is already being done for classes.
2015-08-03 14:12:32 -07:00
Hailee Kenney b1b27a33d3 Merge pull request #41 from iankronquist/nested-classes/pdoc-35
Nested classes/pdoc 35
2015-07-30 14:07:10 -07:00
Ian Kronquist 9083023b33 (maint) Fix typo in emitted html 2015-07-28 13:27:28 -07:00
Ian Kronquist 2d2c03bc33 (PDOC-19) Parse type information for defined types
I forgot to include the code which extracts the type information for the code
object in the defined types handler. Without this we do not extract type
information from defined types so warnings cannot be emitted and types in the
documentation are listed as Unknown.
2015-07-28 13:27:28 -07:00
Ian Kronquist 4dc6bc429a (PDOC-35) Dispatch handlers in correct order
Subclasses have their superclass as part of their namespace and objects in the
subclass's namespace must be registered first.
Reverse the list of parsed objects so
that the classes will be handled and registered in the correct order.
2015-07-21 15:15:30 -07:00
Hailee Kenney 0d8c4e75fe Merge pull request #37 from iankronquist/markdown-madness/PDOC-30
(PDOC-30) Fix Markdown parsing lists parsing
2015-07-20 16:56:51 -07:00
Ian Kronquist 641cba8c2d (maint) Improve message when type error is raised
Addresses @hlindberg's comment after PR #35 was closed.
Use the error message from the exception which is actually exactly what I
wanted to say anyway.
2015-07-16 16:20:49 -07:00
Ian Kronquist 6137e94a25 (PDOC-30) Fix Markdown parsing lists parsing
The transformer comment matching regex matched all whitespace after a comment.
Lines which were effectively "blank" and just had a comment would be erased.
Markdown lists need to end with a blank line. This messed up markdown
formatting.

The culprit is the regex /^\s*#\s/ which matches all of the comment ' #\n',
however we want to leave the newline alone for markdown to parse.
We replace the regex with /^\s*#[ \t]/ which will only match tabs or spaces
after the hash and leave our beloved newline alone.
2015-07-16 11:50:52 -07:00
Ian Kronquist 37d5d08271 (PDOC-19) Fix merge mistakes
* An empty file got added back in the chaos. Delete it again.
* One of the comments was out of date.
2015-07-15 16:35:26 -07:00
Ian Kronquist c4b1d0d10d (PDOC-19) Output type info in generated html 2015-07-15 16:34:08 -07:00
Ian Kronquist 4653a5f9f0 (PDOC-21) Typecheck documented parameters
The documented parameter types should be compared with the actual types when
possible.
2015-07-15 11:58:36 -07:00
Ian Kronquist 081bbfe790 (PDOC-37) Parse 4x function ast type and params
The previous iteration eagerly grabbed all parameters when any puppet function
was created. We did not retrieve type information and would grab parameters
from any helper functions!
* Parse the Ruby AST for dispatch blocks which specify type information. Parse
  the commands and arguments in those blocks.
* If there are no dispatch blocks, parse the AST for a ruby function with the
  same name as the puppet function being created.
2015-07-13 15:42:26 -07:00
Ian Kronquist d37e071ab7 (PDOC-37) Test errors are output properly
Also comment out a statement which we frequently use for debugging which
snuck in by accident.
2015-07-06 10:18:48 -07:00
Ian Kronquist 463d4e0a1f (PDOC-37) Attach params to Puppet 4.x code object
Traverse the ruby AST to get method arguments and attach them to the code
object.
* Fixes spurious warnings issued by yard.
* Obviates the need for ugly regex code in the templates to retrieve
  parameters from the source code.
2015-07-06 10:18:48 -07:00
Ian Kronquist 49171c92b9 (PDOC-37) Warn if parameter names don't match docs
Print the name of the parameter, the file, and the line number to stderr if the
parameter name does not match the name specified in the docs.
In order for this to be useful we need to present the user with the file name
and line number of the relevant parameters. This information needs to be
extracted from the code object and passed to the extract_param_details method.
2015-07-06 10:18:48 -07:00
Hailee Kenney 685ebf54eb (PDOC-25) Fix mangled puppet namespaces
Prior to this commit, puppet namespaces would be totally mangled when
processed by YARD since YARD is looking for Ruby namespaces where the
first letter of each segment must be uppercase.

In order to fix this, patch the relevant regular expression constants
in YARD so that they will accept segments that begin with uppercase
and lowercase letters.

An upstream pull request has been accepted into YARD to add another
regex constant which is necessary to complete this patch. However until
the next version of the YARD gem is released, we must include a temporary
hack to fix the problematic method in question (as it is not yet using
the added variable). Once the new version is released, the conditional
statement in code_ext/yard.rb can be removed entirely and all we will
need to do is patch the two regex constants.
2015-03-12 16:51:00 -07:00
Hailee Kenney 849c731511 (PDOC-27) Make fix compatible with Ruby 2x
Prior to this commit, the fix for the 3x function issue was trying
to create an empty hash by calling Hash[ [[]] ] which in Ruby 1.9.3
produced and empty hash. However this is not the case in Ruby 2.0 and
up. Therefor, fix up the code so that it does not rely on Hash[ [[]] ]
creating and empty hash.
2015-02-17 11:28:26 -08:00
Hailee Kenney 5257ca4bed (PDOC-27) Don't require options for 3x functions
Prior to this commit, the 3x function handler assumed that at
least two arguments (the name and one or more additional arguments)
were passed into newfunction when creating a 3x function. However
that is not actually required, the only argument needed is the name.

Update the 3x function handler so that it will not throw and exception
if only one argument is given.
2015-02-12 14:22:53 -08:00
Hailee Kenney e5691d23c7 (PDOC-26) Rename Puppetx to PuppetX
Due to the changes in PUP-3900 which renamed Puppetx to PuppetX
and puppetx to puppet_x, strings was failing since the namespace
had not been updated in strings. In order to be compatible with this
change, update strings by renaming the namespace to match.

In order to ensure strings is still compatible with earlier versions
of puppet that don't include the namespace change, declare our own
PuppetX module. This way, if it is an older version and the namespace
is called Puppetx, the necessary PuppetX namespace will be created.
2015-02-06 14:08:42 -08:00
Hailee Kenney 26945eacf3 (PDOC-24) Fix comments and remove unneeded sections
Prior to this commit, some of the comments in the code were not as
clear as they should have been and in some places comments were not
present where they were needed. Clean up existing comments and
add some for sections of code that are not very clear.

Additionally, some sections of the template for puppet namespaces
didn't really make sense to include, especially since we want the source
of truth for documentation of 3x functions to be the :doc string which is
passed in (not the comment block above the function). Thus, remove some of
the unneeded sections from the puppet namespace template.
2015-01-28 16:25:22 -08:00
Hailee Kenney 121bcfd2a7 (PDOC-24) Add support for @param in 3x functions
Prior to this commit, the @param tag was not supported for 3x
functions since we could not derive any information about the
parameter from the code itself. Since we would still like users
to be able to document parameters if they wish, update the code so
that if a parameter is documented in the 3x :doc string it will be
displayed in the HTML.
2015-01-28 14:17:20 -08:00
Hailee Kenney b9da8b164f (PDOC-24) Create helper class for templates
Prior to this commit some of the logic used to extract data from
comments for templates was duplicated and a little messy. Create
the TemplateHelper class so that can be simplified and cleaned up
to make things more readable and efficient.
2015-01-22 22:26:58 -08:00
Hailee Kenney 60b2802f04 (PDOC-24) Clean up code for HTML generation
Prior to this commit there was a lot of duplicated code around
the generation of HTML for templates. Clean up and simplify code by
adding an HTMLHelper class with helper functions which can be used
in place of repeated logic.
2015-01-22 15:21:01 -08:00
Hailee Kenney 5f60c99bfd (PDOC-24) Add custom header for puppet functions
Prior to this commit, all the HTML for puppet functions was just
generated by YARD as if it were a regular method. Since we ultimately
want to have our own custom templates, lay out the groundwork for customizing
the templates for functions and update the page headers to be more
readable.

At the moment the code is functional but contains a lot of duplication which
needs to be cleaned up.
2015-01-21 16:03:35 -08:00
Hailee Kenney 1fae19e5ae (PDOC-17) htmlify class/defined type descriptions
Prior to this commit we were not calling htmlify on the docstring
for the description of a puppet class on defined type. This meant that
the raw string would be displayed without paying attention to any
potential markdown or rdoc formatting present.

Now the YARD method htmlify is being called on the docstring so that
it will be displayed properly.

Additionally clean up an unclear comment and fix a small bug in
the way parameter information is processed.
2015-01-06 10:59:30 -08:00
Hailee Kenney e85f58a64e (PDOC-17) Changed header and remove sub-header
Prior to this commit there was a header and a sub-header for
defined types and classes. This was a little redundant so rather
than doing that, remove the sub-header and make the main header
more readable.
2014-12-30 15:20:59 -08:00
Hailee Kenney 1f2d9a2d8a (PDOC-17) Clean up code and update README
Do a bit of renaming and add some comments to make the processing
of parameter details a bit more clear. Additionally, update the
example in the README so that it will actually be parsed properly
by YARD (since YARD does not expect the one line title before the
description).
2014-12-18 13:34:43 -08:00
Hailee Kenney d15269458e (PDOC-17) Add TBD for unspecified parameter types
Prior to this commit if the type for a parameter was not specified
in the comment, nothing would be printed. Since we'll soon be adding
functionality which will determine the type programmatically, it
made more since to leave a place holder rather than nothing at all.
As such, the type is now listed as "TBD" if it is not specified
by the user in the comment.
2014-12-18 10:40:22 -08:00
Hailee Kenney 1cdf7d41e9 (PDOC-17) Fix up parameter documentation
Prior to this commit there were a few issues in the way information
about parameters was collected. The previous implementation relied
on parameters and their corresponding comments to be listed in the
same order. Now the parameter is matched to the corresponding comment
using the parameter name in the comment.

Additionally, if a comment is present for a parameter that does
not actually exist in the method it will appear as strike through
in the HTML.
2014-12-17 16:39:56 -08:00
Hailee Kenney de3c1e776d (PDOC-17) Add support for YARD tags in puppet code
Prior to this commit, most of the HTML created for documenting
puppet code was auto-generated by YARD, meaning that it was not
always presented in a way that was consistent or easy to read.

Now we are explicitly defining the HTML and styling that we want
to use when generating documentation for defined types and classes.
This means that we can define exactly how we want the output to look
so that is more compatible with puppet code.
2014-11-25 14:44:49 -08:00
Henrik Lindberg 0a3c60a260 Merge pull request #19 from hkenney/issue/master/pdoc14_fix_strings_for_future_parser
(PDOC-14) Fix strings to work with future parser
2014-10-14 16:32:22 -07:00
Hailee Kenney 9d53a8091a (PDOC-14) Fix strings to work with future parser
Prior to this commit, two require statements were in the wrong
order, causing strings to fail when running against anything that
required the future parser.

Now, those requires have been flipped and strings can run with
`--parser future` successfully.
2014-10-13 08:29:15 -07:00
Hailee Kenney 999daa9c4c (PDOC-8) Fix present rubocop offenses
Since we want to run rubocop in travis when pull requests are
submitted, fix a few pre-existing rubocop offenses.
2014-10-08 11:36:21 -07:00
Hailee Kenney fa8af6693d (maint) Fix incorrectly resolved merge conflict
Due to a merge conflict that was not properly resolved, a method
which did not exist was being called in the server action, causing
the action to fail. Remove the unneeded method call so that the
server action will work as intended.
2014-10-01 11:32:12 -07:00
Hailee Kenney 6d1d5b496d (PDOC-3) Relocate plugin configuration
The plugin.rb file really only did configuration of components that were already loaded.
By relocating to the strings.rb file, it provides a central place for all of the loading
and configuration of the strings components.
2014-09-30 14:21:20 -07:00
Hailee Kenney 14571c098d (PDOC-3) Make references to YARD explicit
The specs were including YARD into the Kernel, which allowed shorter references to the Registry, but also obscured that
the Registry is part of YARD.
2014-09-30 14:02:31 -07:00
Hailee Kenney 5159a7b778 (PDOC-3) Move requires to top level scope
Prior to this commit, the requires for the puppetx portion of this
project were dealt with in each individual file. In order to make
the code more readable and the requires more clear, move them all
into the strings file.
2014-09-30 13:55:11 -07:00
Hailee Kenney f0da72b2b7 (PDOC-3) Switch to one line class declarations
Prior to this commit, many of the classes in this project were declared
in two lines. The first line would put them in the context of the module
they belonged to, and the second line would declare the class and deal with
inheritance. In order to make the code more readable and to allow
require statements to be moved to the top level, turn all class declarations
into one line statements.
2014-09-30 13:55:11 -07:00
Hailee Kenney df648a246f (PDOC-3) Use require instead of require_relative
Prior to this commit, the puppet strings project was using require_relative
to include other classes and modules. Due to some ambiguity and the fact
that the strings project shares some naming conventions with YARD, the
use of require_relative sometimes made it unclear what was being
included and where it was coming from. Now require is being used and although
this requires the full path, it makes it very clear where things are coming
from.
2014-09-30 13:55:11 -07:00
Hailee Kenney 4c53f049e1 (PDOC-3) Change actions from module to class
Refactor the actions module so that it is a class. This is important
because it allows us to keep `Puppet[]` calls out of the library and
have them in the face itself. Additionally, move a few things around
(like `check_required_features` since it makes require statements
cleaner) and clean up some comments.
2014-09-30 13:55:11 -07:00
Hailee Kenney 94ff0a4445 (PDOC-3) Add method headers for new libraries
Add some comments for the new methods that have been introduced
to ensure that the code is readable and well documented.
2014-09-30 13:55:10 -07:00
Hailee Kenney 58fef9e8f6 (PDOC-3) Refactor face and remove modules action
Refactor the code in the strings face and extract much of the functionality
into a separate library in order to make the code more readable and
sustainable. Additionally, remove the `modules` action from the face
since it does not have a clear use case currently. However since the `server`
action depends on it, and it may be helpful to add other features in the future,
extract the functionality previously contained in `modules` into a helper
method.
2014-09-30 13:55:10 -07:00
Peter Souter 5304b4f2c1 Add -q option to suppress warnings for server 2014-09-23 00:54:28 +01:00
Hailee Kenney ebbc2936df (PDOC-3) Rename FutureParser and ParserFunctions
Prior to this commit, the handlers and code objects which dealt with
puppet functions were referred to as `FutureParserFunctions` and
`ParseFunctions`. This naming convention will not make very much
sense going forward when the future parser becomes the primary
parser. Therefor, rename `FutureParserFunctions` to `Puppet4xFunctions`
and `ParserFunctions` to `Puppet3xFunctions`.
2014-09-17 10:10:38 -07:00
Hailee Kenney dabcdf7f06 (PDOC-3) Add puppetlabs directory
In order to keep with conventions around directory structure, add
a puppetlabs directory and rename modules accordingly.
2014-09-16 09:07:59 -07:00
Hailee Kenney ec0e26e339 (PDOC-3) Rename face to strings instead of yardoc
Since we don't want the name of the tool to reflect the fact that
it is using yard internally (this is an implementation detail), rename
the face to `strings`. Now when one wishes to generate documentation,
`puppet strings` will be used rather than `puppet yardoc`.
2014-09-11 09:57:19 -07:00
Hailee Kenney 195374d2a7 (PDOC-5) Add spec testing for face component
Add spec tests for Puppet face component, mainly around error checking.
Due to the use of `puppet module list`, the behavior of the `modules`
and `server` actions are not very feasible to test via spec testing.

Additionally, make a few minor changes to the gem file, and make a
small change in `check_required_features` to reflect the fact that
this module will no longer support anything earlier than Ruby 1.9.
2014-09-03 14:27:48 -07:00
Charlie Sharpsteen 1d81aacf5a Recurse into 4.x functions and process dispatches
This patch recurses into any `create_function` block and processes any
`dispactch` blocks contained within. The implementation assumes docstrings will
be provided as a comment block, but this is just a temporary placeholder.

Idealy, the contents of the `dispatch` block would be processed to produce an
`@override` tag for 4.x functions.
2014-08-06 14:59:27 -07:00
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 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 043fb34721 Add docstrings to yardoc face 2014-05-31 23:24:27 -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 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