Commit Graph

80 Commits

Author SHA1 Message Date
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
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 2f7c9e1888 Merge pull request #6 from petems/supress_yard_warnings
Add -q option to suppress warnings for server
2014-09-30 11:53:56 -07:00
Andrew Parker e2e2880473 Merge pull request #10 from hkenney/issue/master/pdoc-7-setup-travis-ci-for-project
(PDOC-7) Add .travis file for Travis CI support
2014-09-26 12:12:21 -07:00
Hailee Kenney c2f76543e7 (PDOC-7) Add .travis file for Travis CI support
Since we want Travis CI to run spec tests for pull requests opened
for puppet strings, add a .travis.yml file so that Travis CI can
run spec tests.
2014-09-25 09:28:41 -07:00
Roger Ignazio f267faf628 Merge pull request #9 from hkenney/issue/master/pdoc-6-update-gemfile-for-jenkins-jobs
(PDOC-6) Allow for different puppet gem versions
2014-09-25 09:02:30 -07:00
Hailee Kenney 583ddcb6ad (PDOC-6) Allow for different puppet gem versions
In order to make the Gemfile compatible with the puppet strings
Jenkins job (which tests against multiple versions of puppet), update
the Gemfile to allow for for the Jenkins job to specify which version
of puppet it is testing against.
2014-09-24 14:09:31 -07:00
Peter Souter 5304b4f2c1 Add -q option to suppress warnings for server 2014-09-23 00:54:28 +01:00
Andrew Parker 6fb4a39536 Merge pull request #4 from hkenney/PDOC-3_refactor-prototype-code
(PDOC-3) Rename face to strings instead of yardoc
2014-09-17 10:32: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
Andrew Parker ac3bbbd4d2 Merge pull request #3 from hkenney/PDOC-2_add_high_level_tests_for_face
(PDOC-2) Improve test coverage for puppet strings
2014-09-15 11:03:08 -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
Hailee Kenney 2ebde0a21e (PDOC-2) Refactor tests for 3x function handler
Rework the tests around the 3x function handler. Make them more
verbose by having them them test against multiple examples and by making
the checking of the Registry more details.
2014-09-09 13:43:30 -07:00
Hailee Kenney 74a946fcfe (PDOC-2) Refactor tests for defined type handler
Like the 4x function handler tests, the tests around the defined
type handler were not very specific and didn't use multiple examples.
Update the tests so that they do more than just ensure that the right
objects were added to the Registry and cover a few different cases
instead of just one.
2014-09-09 11:38:41 -07:00
Hailee Kenney d5ffc4d8da (PDOC-2) Refactor tests for 4x function handler
Update the spec tests which cover the Puppet 4x function handler
to be more specific and cover different test cases. Prior to this commit,
they would simply check that the right objects had been added to the
Registry for one example. Now, they examine multiple examples and ensure that
the code objects not only exist but that the details about them are what we
would expect for each specific scenario.
2014-09-08 15:39:31 -07:00
Hailee Kenney 4c303a0258 (PDOC-2) Add tests around face and HTML generation
Add tests to ensure that the face (puppet yardoc) works from end to
end. In other words, ensure that when given a module, puppet yardoc can
successfully evaluate the .pp and .rb files present in the module and
produce the expected HTML.
2014-09-05 14:10:55 -07:00
Hailee Kenney 7728c82615 (maint) Update Gemfile to require redcarpet gem
Update the project Gemfile to include the redcarpet gem. This
particular gem is needed for Markdown processing.
2014-09-04 20:18:16 -07:00
Hailee Kenney 3f81f44df2 (maint) Update .gitignore to ignore .yardoc files
When YARD produces documentation, it also adds a .yardoc file.
Update the .gitignore for this project to ignore these files.
2014-09-04 17:04:16 -07:00
Andrew Parker 39f4ca1d09 Merge pull request #2 from hkenney/PUP-3086_add-basic-spec-tests
(PDOC-5) Add basic unit testing
2014-09-04 10:20:00 -07:00
Hailee Kenney 645f35ccfe (PDOC-5) Remove unneeded test case
Remove an unneeded test case. Since it would be caught even in a very
basic system, an automated test case is not needed.
2014-09-03 15:41:07 -07:00
Hailee Kenney b2267fcfc6 (PDOC-5) Test host classes and 3x functions
Add tests for the remaining two Puppet-specific handlers that were
not tested in the previous commit. Specifically, add tests for the
3.x function handler and the host class handler.
2014-09-03 15:41:00 -07:00
Hailee Kenney 8549bf7eff (PDOC-5) Test defined types and 4x functions
Begin to test the YARD handlers written for the puppet language.
Add basic tests for the defined type and puppet 4 function
handlers. In addition, make changes to the spec helper to make it
easier to work with YARD Registries for testing purposes.
2014-09-03 14:28:19 -07:00
Hailee Kenney 766fd57ebe (PDOC-5) Add spec testing for pops component
Prior to this commit there was no testing around the pops component.
Since most of the API in the pops component is private, there aren't
very many things to test, so add just a few test cases.

Additionally rename a previous spec file and make some changes to
the Gemfile.
2014-09-03 14:28:06 -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
Hailee Kenney 686e60c791 Add project Gemfile
Prior to this commit there was no Gemfile for this project. Now
a Gemfile has been added so that those developing the project
can take advantage of Bundler.
2014-08-15 10:21:09 -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 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