Commit Graph

79 Commits

Author SHA1 Message Date
Will Hopper f8c5628b66 (PDOC-125) Update JSON schema to reflect addition of `signatures` 2016-11-14 13:22:42 -08:00
Will Hopper e4df165489 (PDOC-125) Update JSON tests for `signatures` key 2016-11-14 13:05:07 -08:00
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
Will Hopper be0e93e3d6 (maint) Update line number in fixture to fix specs 2016-10-11 16:49:36 -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
Henrik Lindberg 7c475a5095 Merge pull request #105 from whopper/maint/code_coverage
(PDOC-88) Add additional spec and acceptance tests
2016-10-03 13:53:05 +02:00
Will Hopper c5e3d488da (PDOC-106) Add acceptance test for --emit-json CLI options 2016-09-30 16:35:48 -07:00
Will Hopper 3b66f5888f (maint) Refactor `generate` test to use acceptance helper method 2016-09-30 16:35:42 -07:00
Will Hopper 132d39066c (maint) Add acceptance libdir and Util helper module 2016-09-30 16:35:32 -07:00
Will Hopper 3af15ce4f1 (PDOC-88) Add tests for types and providers into acceptance 2016-09-30 15:08:19 -07:00
Will Hopper beb79d3a63 (PDOC-88) Add acceptance test for puppet functions 2016-09-30 13:39:09 -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 e5577e199c
(PDOC-63) Restore acceptance test to the spec directory.
Previously the acceptance test was implemented under the `spec` directory and
was moved out to a top level `acceptance` directory.

This broke the expected location for the node configuration files.

This commit puts the acceptance test back where it was previously.

Also fixes a failure in the test now that Markdown is the default markup
language used.
2016-09-16 15:42:00 -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 7897c70a52
(maint) RuboCop fixes.
This commit fixes a few RuboCop related failures.
2016-09-15 17:15:54 -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
Spencer McElmurry c6de41e6b9 (QENG-3888) Remove static nodeset, use beaker-hostgenerator
This is additional work for QENG-3888 in ci-job-configs. We were using static
nodesets within specs/acceptance/nodesets before and this commit will instead use beaker-hostgenerator
to get the specified platform .yml configurations.
2016-06-20 14:13:41 -07:00
Hailee Kenney a6e5a806be (maint) Update hostfile for acceptance test
Prior to this commit, strings had a hostfile that was using an old
format that is no longer compatible with beaker which was causing
the acceptance tests to fail.

Update the hostfile so that it works.
2016-05-11 16:05:02 -07:00
Hailee Kenney b8a23d3617 (maint) Update acceptance tests to use gem
Prior to this commit, the acceptance tests were trying to install
strings as a module and failing due to the fact that strings has
transition to a gem and does not have metadata. Update the tests
so that they install strings as a gem instead.
2016-05-02 15:00:38 -07:00
Hailee Kenney 91b46be4ea (maint) Remove deprecated rspec method
Prior to this commit, strings relied on failure_message_for_should
which produced a deprecation warning. Use the suggested alternative
'failure_message' instead to removed the deprecation warning and
ensure the tests are up to date.
2016-03-24 16:01:21 -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
Hailee Kenney c8fbe3c20f Merge pull request #31 from iankronquist/warn-when-not-matching/PDOC-21
(PDOC-37) Warn when documented name does not match declared name
2015-07-06 20:06:08 -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
Hailee Kenney 3edf7347df (maint) Remove rspec-html-matchers from acceptance
Prior to this commit, the acceptance tests were using the
rspec-html-matchers gem which we had removed because it does not
work with rspec 3.

In order to make the acceptance tests compatible with this change,
use string matching to check the HTML output instead and remove
the dependency on that gem.
2015-07-06 11:55:59 -07:00