Commit Graph

59 Commits

Author SHA1 Message Date
Will Hopper c56d9c60a4 (PDOC-129) Include tags in overload objects when serialized as JSON
Previously, overload objects were not displaying their tags when
they had no docstring text. This was due to an issue in the overload
`to_hash` method, which prevented the tags from being serialized when
the dispatch had no top-level text. This commit updates that logic
so that the tags will always be included in the hash if they exist.
2016-11-14 11:45:45 -08:00
Jesse Scott df8e58b0c8 Merge pull request #125 from whopper/PDOC-135/4x_dispatch_return_type
(PDOC-135) Detect `return_type` calls in 4.x function dispatches
2016-11-14 11:37:05 -08:00
Will Hopper 36bc0dd98c (PDOC-135) Detect `return_type` calls in 4.x function dispatches
Previously, Strings ignored calls to `return_type` in Puppet 4.x API
function dispatches, preventing the return types of overloads from
being automatically determined. This commit adds a check for a node
with a `return_type` call and handles it properly.
2016-11-14 11:04:41 -08:00
Will Hopper b3c8d52b25 (PDOC-136) Detect return type syntax in Puppet language functions
Previously, Strings ignored the return type in Puppet language functions
that used the following syntax:

function foo() >> String {}

This commit updates the FunctionStatement class to use the return
type from such a statement if it exists. In addition, Strings will
now emit a warning if the return type specified in the @return tag
doesn't match the type specified in the function definition.
2016-11-11 14:47:35 -08:00
Will Hopper c4705d9705 (PDOC-126) Add spec test for util module and scrub_string method 2016-10-28 11:54:48 -07:00
Will Hopper e291f8cfe9 (PDOC-126) Remove `%Q` ruby quotation syntax from parsed strings
Previously, YARD would parse ruby strings which used %Q notation
and return the syntax literally. This commit adds a new Util
module with a `scrub_string` method to check for such a string
and remove the errant %Q and %q's.
2016-10-28 11:54:34 -07:00
Peter Huene 4f3f1e639e Merge pull request #111 from whopper/PDOC-95/master/multiple_defaultfor
(PDOC-95) Properly group and display multiple provider `defaultfor`s
2016-10-11 15:33:39 -07:00
Will Hopper d0f1fb7174 (PDOC-127) Strip whitespace from type feature docstrings 2016-10-11 14:48:02 -07:00
Will Hopper a5a3d6b48c (PDOC-95) Properly group and display multiple provider `defaultfor`s
Prior to this commit, strings did not properly handle providers
which had multiple related `defaultfor`s. In code, these are written
as comma-separated constraints. This commit updates strings' puppet
provider handler, as well as the template which generates HTML for
`defaultfor` statements.

Note that it was necessary to make a breaking change to the JSON
schema to accomodate multiple AND'ed defaults. Previously, provider
defaults were contained in a single key-value map. Now, they are
contained in an array of key-value lists, which allows multiple
constraints to be associated with each other.
2016-10-11 13:57:00 -07:00
Will Hopper ca98890cdd (PDOC-122) Properly parse `newfunction` calls with newlines
When `newfunction` is separated from the Puppet::Parser::Functions module name by a
newline, YARD ignores the namespace and uses `newfunction` as the source of the
first statement.

Prior to this commit, strings didn't recognize this case, and 3.x functions written
in this way were not parsed as functions. This commit updates the ruby function handler
to identify and properly parse 3.x functions that include a newline between the
Puppet::Parser::Function namespace and the newfunction method call.
2016-10-10 15:27:23 -07:00
Will Hopper ef6db6df41 (PDOC-88) Add additional spec tests to increase code coverage 2016-09-29 14:48:07 -07:00
Peter Huene 9ba9b56306
(PDOC-63) Fix specs for Puppet versions less than 4.1.
The specs test functions written in the Puppet language in a few places, but
this feature is only supported in Puppet 4.1+.  This commit prevents these
specs from running if targeting older versions of Puppet.
2016-09-16 12:16:35 -07:00
Peter Huene cf77ef1379
(PDOC-63) Add specs to test the new implementation.
This commit adds specs to cover parts of the new implementation of Puppet
Strings.
2016-09-15 17:15:54 -07:00
Peter Huene ea9dd0c846
(PDOC-63) Delete the old implementation.
This commit deletes the old implementation to assist in cleaner code reviews of
the upcoming reimplementation.

This commit also moves YARD to version 0.9.5 and lays down a bare bones
implementation of Puppet Strings that currently does nothing.
2016-09-15 13:54:18 -07:00
Peter Huene 56f266db4b
(maint) Rename puppetlab-strings to puppet-strings where appropriate.
This commit changes the source and documentation to reference this project as
`puppet-strings` rather than `puppetlabs-strings`.

This makes the source and project match the gem name.
2016-09-14 13:42:28 -07:00
Ian Kronquist a9a387a05a (PDOC-23) Define JSON Structure for Puppet code 2015-10-16 15:50:04 -07:00
Hailee Kenney d965d06bca Merge pull request #61 from iankronquist/same-name-type-and-provider
Same name type and provider
2015-09-21 16:47:34 -07:00
Ian Kronquist 3151e4e1b1 (PDOC-56) Fix type warning for defined types
Puppet defined types would print the string representation of the ruby object,
and not representation you would see in puppet. This is the difference between
`Puppet::Pops::Types::PStringType` and `String`.
2015-09-18 16:17:02 -07:00
Ian Kronquist 7814eeaf3c (PDOC-54) Providers & Types w/same name conflict
If a provider and a type with the same name conflict strings will overwrite the
documentation of one of them with the other. That is if both a provider and a
type are named apt_key, strings will write the type to doc/apt_key.html and the
provider to doc/apt_key.html. The fix is to write the provider to
doc/apt_key_provider.html and the type to doc/apt_key_type.html.
2015-09-16 16:47:59 -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 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 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
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 c4a1a10c67 (PDOC-45) Test Puppet 4x functions don't throw
Parsing puppet 4x functions with symbols for their names like :'defined' should
not raise ParseErrorWithIssue, or anything for that matter.
2015-09-01 15:42:37 -07:00
Ian Kronquist f5c4c4c861 (PDOC-21) Test for duplicate hostclass warnings
* Add testing file based off shaigy's tests.
* Refactor using_module into a helper class.
* Expect that the warnings printed to stdout are *exactly* what I want to see
  and nothing else.
2015-08-19 10:50:03 -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 457ec86a2b (PDOC-35) Test strings works with nested classes 2015-07-28 14:56:14 -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 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 8b3cdd3a51 (PDOC-37) Add additional tests for parameter names
* Test positive cases (warnings AREN'T printed when they shouldn't be)
* Test puppet functions which use dispatches
2015-07-08 16:09:36 -07:00
Ian Kronquist 168c1c4b53 (PDOC-37) Override Yard logger on a per test basis
Override Yard logger on a per test basis, not globally.
Replace one hack with another slightly less disgusting one.
2015-07-06 16:40:30 -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
Hailee Kenney 917d9b6536 (maint) Remove html-matchers dependency
Prior to this commit, some of the unit tests for strings relied on
the rspec-html-matchers gem, which does not seem to get along with
rspec 3. This meant that we had to tie our tests to rspec 2 which
has become too inconvenient.

In order to remove the gem, use simple string matching instead.
Update the Gemfile so that it no longer requires the matchers and
no longer has rspec tied to 2.7.
2015-07-02 15:12:49 -07:00
Hailee Kenney 862b090221 (PDOC-25) Add tests to ensure namespaces are correct
Prior to this commit, there were no tests to check if namespaces
were being properly generated (which was why we did not catch the
bug earlier). Add a test for defined type and host class handlers
to ensure that namespaces are properly generated in code objects.
2015-03-13 10:48:29 -07:00
Hailee Kenney 0a3c37373c (maint) Update Gemfile to use rspec 2.14.0
Prior to this commit, the Gemfile for strings did not specify which
version of rspec to use. When it started using rspec 3, the tests
that relied upon the rspec-html-matchers gem began to fail, likely
because that gem is not yet compatible with the new version of rspec.

Update the Gemfile so that we explicitly use an older version of
rspec to prevent tests from failing. We will have to either wait
for rspec-html-matchers to catch up or find a new way of testing
the HTML output before we can update to rspec 3.
2015-02-13 15:53:22 -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 aea5c9537f (PDOC-9) Switch to metadata.json for test module
Prior to this commit, the test module used in testing was using
a Modulefile rather than metadata.json. Switch to metadata.json
instead since Modulefile is deprecated and was causing a deprecation
warning during acceptance testing.
2014-10-06 10:21:58 -07:00
Hailee Kenney ee6997cd24 (PDOC-9) Add preliminary full system test
In order to help ensure that the strings module is not broken
during development, add a full system integration test which can
run at regular intervals to ensure that the module is working as
expected.

The test installs the string module as well as a test module which
contains the different types of puppet and ruby code that the strings
module can document. It then runs strings and ensures that the HTML
generated is correct.

Additionally, make some changes to the Gemfile to allow strings to
be run as a gem even if it isn't installed in the modulepath. Also
make a few changes to the unit tests to make them compatible with
the version of rspec required by Beaker.
2014-10-06 10:08:30 -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 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
Hailee Kenney 322dbfcc1e (PDOC-3) Use constants instead of strings in tests
Prior to this commit, several rspec tests were using `decribe "string"'
instead of `describe constant`. Update the tests to use the constant instead.
Additionally, rename the puppet function tests to reflect the renaming of the
handlers.
2014-09-30 13:52:31 -07: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 376ceb762c (PDOC-2) Split up handler specs
In order to make the code more readable, separate the tests into
different files for each handler. Additionally, extract the helper
methods into a separate module which may be included as needed.
2014-09-10 11:11:22 -07:00
Hailee Kenney c56d9fc27a (PDOC-2) Refactor tests for host class handler
Update the tests around the host class handler so that they test
several different examples as opposed to just one. Additionally,
refactor the tests so that they are more detailed when it comes to
checking if the Registry is in the correct state after code has been
parsed.
2014-09-09 14:57:31 -07:00