Commit Graph

110 Commits

Author SHA1 Message Date
Ian Kronquist 8aab1ea0a3 (maint) Remove debug statement on unusual path 2015-09-16 14:43:27 -07:00
Hailee Kenney 3c885cf550 Merge pull request #59 from iankronquist/puppet-type-list-linebreak-pdoc-35
(PDOC-35) Format generated html properly
2015-09-15 15:39:36 -07:00
Ian Kronquist 7f4b81e77b (PDOC-53) Handle directives with no types
Parameter directives with no types will have `tag.type` set to nil. We cannot
append nil to an array, so instead, place it in the array and flatten the
array. If the property is empty the second entry in the array will be nil, as
we expect. If the `tag.type` is an array of types we will have and array with
the form:
	[tag.text, type1, type2, type3, ...]
2015-09-15 09:57:46 -07:00
Ian Kronquist d2c178b59c (PDOC-52) Register docstring after object
In a Puppet type if the user documents a parameter with the directive, then
Yard will read the parameter and think there is an empty docstring there. This
will overwrite the docstring we extracted.
The fix is simple -- overwrite our docstring with theirs, if our docstring
exists at all.
2015-09-15 09:55:50 -07:00
Ian Kronquist 1b421939d4 (PDOC-35) Format generated html properly
Shaigy Nixon on Jira:
"Just a trivial thing. Looks like one line break is missing from the type's
output html between the property and the allowed values for parameter. Rest all
looks great."
https://tickets.puppetlabs.com/browse/PDOC-35?focusedCommentId=215400&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-215400

As an aside, I would really like to rewrite this method to be a real erb
template and not this nonsense.
2015-09-14 12:03:43 -07:00
Ian Kronquist e26cb69d36 (PDOC-49) Improve warnings
1. Long warning should be broken onto multiple lines.
2. Warnings should begin with `[warn]:`
2015-09-11 14:30:14 -07:00
Ian Kronquist 1991475b4c (PDOC-35) Fix formatting from Nick's suggestions
* Float several namevars/ensurables to top of list
* Fix minor code style issues
2015-09-09 15:27:50 -07:00
Ian Kronquist 0206c78ee0 (PDOC-35) Document types & providers separately
* Dunno, I just plowed through a bunch of features
* Expect puppet provider in stats output
* Fetch default values for Type params and props
* Detect allowed values
* Add allowed values to test
* htmlify scrubbed text
* Add features to Type html output
* Add infrastructure for types
* Add methods for generating lists, etc.
* Add provider code object
* Add provider handler
* Generate list for puppet provider dropdown
* Add puppet provider template
* Add provider details to puppet type template
* Get description properly for types
2015-09-09 14:35:45 -07:00
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