-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently, puppet-strings does not know how to generate documentation for Puppet Tasks. This does all the work to add support for Tasks including a new JSON parser, a task handler, task statement, and task code object. Basically, Strings reads the JSON using the native ruby json parser and sends values through in a way it understands. It is only passing json key/value pairs through, nothing is happening with tags at this time. You can now document Tasks and generate HTML, Markdown, or JSON output.
- Loading branch information
Showing
9 changed files
with
137 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 1 addition & 7 deletions
8
lib/puppet-strings/yard/templates/default/puppet_task/html/input.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
<% if json['input_method'] || json['supports_noop'] %> | ||
<div class="tags"> | ||
<p class="tag_title"> Input </p> | ||
<ul> | ||
<% if json['input_method'] %> | ||
<li> Input method: <%= json['input_method'] %> </li> | ||
<% end %> | ||
<li> Supports noop? <%= json['supports_noop'] ? "true" : "false" %></li> | ||
</ul> | ||
<p><strong>Supports noop?</strong> <%= json['supports_noop'] ? "true" : "false" %></p> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
require 'spec_helper' | ||
|
||
describe PuppetStrings::Yard::Parsers::JSON::TaskStatement do | ||
let(:source) { <<-SOURCE | ||
{ | ||
"description": "Allows you to backup your database to local file.", | ||
"input_method": "stdin", | ||
"parameters": { | ||
"database": { | ||
"description": "Database to connect to", | ||
"type": "Optional[String[1]]" | ||
}, | ||
"user": { | ||
"description": "The user", | ||
"type": "Optional[String[1]]" | ||
}, | ||
"password": { | ||
"description": "The password", | ||
"type": "Optional[String[1]]" | ||
}, | ||
"sql": { | ||
"description": "Path to file you want backup to", | ||
"type": "String[1]" | ||
} | ||
} | ||
} | ||
SOURCE | ||
} | ||
let(:json) { JSON.parse(source) } | ||
subject { PuppetStrings::Yard::Parsers::JSON::TaskStatement.new(json, source, "test.json") } | ||
describe '#comments' do | ||
it 'returns docstring' do | ||
expect(subject.comments).to eq "Allows you to backup your database to local file." | ||
end | ||
end | ||
describe '#parameters' do | ||
context 'with params' do | ||
it 'returns params' do | ||
expect(subject.parameters.size > 0).to be true | ||
end | ||
end | ||
context 'no params' do | ||
let(:source) { <<-SOURCE | ||
{ | ||
"description": "Allows you to backup your database to local file.", | ||
"input_method": "stdin" | ||
} | ||
SOURCE | ||
} | ||
it 'returns an empty hash' do | ||
expect(subject.parameters).to eq({}) | ||
end | ||
end | ||
end | ||
|
||
end |