summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2019-07-07 15:14:22 -0700
committerTim Smith <tsmith84@gmail.com>2019-07-07 15:14:22 -0700
commit316551ba27ce6cf683eb6c429210ccb7ae8b7cc9 (patch)
treeee956cca0112b065d40e949a0c05d1dee1e39e03
parent85914b32f9010aacca472f93b13784825a67102f (diff)
downloadchef-316551ba27ce6cf683eb6c429210ccb7ae8b7cc9.tar.gz
Improve generation of docs site resource pages
1) Fix the indentation 2) Avoid extra new lines 3) Show example data if we have it 4) Chef Infra Client vs. the Chef Infra Client Signed-off-by: Tim Smith <tsmith@chef.io>
-rwxr-xr-xtasks/docs.rb119
1 files changed, 61 insertions, 58 deletions
diff --git a/tasks/docs.rb b/tasks/docs.rb
index 0adebce0b6..a468ddea58 100755
--- a/tasks/docs.rb
+++ b/tasks/docs.rb
@@ -139,7 +139,7 @@ namespace :docs_site do
``sensitive``
**Ruby Type:** true, false | **Default Value:** ``false``
- Ensure that sensitive resource data is not logged by the Chef Infra Client.
+ Ensure that sensitive resource data is not logged by Chef Infra Client.
.. end_tag
@@ -255,62 +255,64 @@ namespace :docs_site do
HEREDOC
end
- template = %{=====================================================
- <%= @name %> resource
- =====================================================
- `[edit on GitHub] <https://github.com/chef/chef-web-docs/blob/master/chef_master/source/resource_<%= @name %>.rst>`__
-
- <%= bolded_description(@name, @description) %>
- <%= note_text(@description) %>
- <% unless @introduced.nil? %>
- **New in Chef Infra Client <%= @introduced %>.**
- <% end %>
- Syntax
- =====================================================
- The <%= @name %> resource has the following syntax:
-
- .. code-block:: ruby
-
- <%= @resource_block %>
-
- where:
-
- * ``<%= @name %>`` is the resource.
- * ``name`` is the name given to the resource block.
- * ``action`` identifies which steps the Chef Infra Client will take to bring the node into the desired state.
- <% unless @property_list.nil? %>* <%= @property_list %><% end %>
-
- Actions
- =====================================================
-
- The <%= @name %> resource has the following actions:
- <% @actions.each do |a| %>
- ``:<%= a %>``
- <% if a == @default_action %>Default. <% end %>Description here.
- <% end %>
- ``:nothing``
- .. tag resources_common_actions_nothing
-
- This resource block does not act unless notified by another resource to take action. Once notified, this resource block either runs immediately or is queued up to run at the end of the Chef Infra Client run.
-
- .. end_tag
-
- Properties
- =====================================================
-
- The <%= @name %> resource has the following properties:
- <% @properties.each do |p| %>
- ``<%= p['name'] %>``
- **Ruby Type:** <%= friendly_types_list(p['is']) %><% unless pretty_default(p['default']).nil? %> | **Default Value:** ``<%= pretty_default(p['default']) %>``<% end %><% if p['required'] %> | ``REQUIRED``<% end %><% if p['deprecated'] %> | ``DEPRECATED``<% end %><% if p['name_property'] %> | **Default Value:** ``The resource block's name``<% end %>
-
- <%= p['description'] %>
- <% unless p['introduced'].nil? %>\n *New in Chef Infra Client <%= p['introduced'] %>.*<% end %>
- <% end %>
- <% if @properties.empty? %>This resource does not have any properties.\n<% end %>
- <%= boilerplate_content %>
- Examples
- ==========================================
- }
+ template = %{
+=====================================================
+<%= @name %> resource
+=====================================================
+`[edit on GitHub] <https://github.com/chef/chef-web-docs/blob/master/chef_master/source/resource_<%= @name %>.rst>`__
+
+<%= bolded_description(@name, @description) %>
+<%= note_text(@description) %>
+<% unless @introduced.nil? %>
+**New in Chef Infra Client <%= @introduced %>.**
+<% end %>
+Syntax
+=====================================================
+The <%= @name %> resource has the following syntax:
+
+.. code-block:: ruby
+
+<%= @resource_block %>
+
+where:
+
+* ``<%= @name %>`` is the resource.
+* ``name`` is the name given to the resource block.
+* ``action`` identifies which steps Chef Infra Client will take to bring the node into the desired state.
+<% unless @property_list.nil? %>* <%= @property_list %><% end %>
+
+Actions
+=====================================================
+
+The <%= @name %> resource has the following actions:
+<% @actions.each do |a| %>
+``:<%= a %>``
+ <% if a == @default_action %>Default. <% end %>Description here.
+<% end %>
+``:nothing``
+ .. tag resources_common_actions_nothing
+
+ This resource block does not act unless notified by another resource to take action. Once notified, this resource block either runs immediately or is queued up to run at the end of the Chef Infra Client run.
+
+ .. end_tag
+
+Properties
+=====================================================
+
+The <%= @name %> resource has the following properties:
+<% @properties.each do |p| %>
+``<%= p['name'] %>``
+ **Ruby Type:** <%= friendly_types_list(p['is']) %><% unless pretty_default(p['default']).nil? %> | **Default Value:** ``<%= pretty_default(p['default']) %>``<% end %><% if p['required'] %> | ``REQUIRED``<% end %><% if p['deprecated'] %> | ``DEPRECATED``<% end %><% if p['name_property'] %> | **Default Value:** ``The resource block's name``<% end %>
+
+ <%= p['description'] %>
+<% unless p['introduced'].nil? -%>\n *New in Chef Infra Client <%= p['introduced'] -%>.*<% end -%>
+<% end %>
+<% if @properties.empty? %>This resource does not have any properties.\n<% end %>
+<%= boilerplate_content %>
+Examples
+==========================================
+<%= @examples -%>
+}
FileUtils.mkdir_p "docs_site"
resources = Chef::JSONCompat.parse(ResourceInspector.inspect)
@@ -327,8 +329,9 @@ namespace :docs_site do
@properties = data["properties"].reject { |v| v["name"] == "name" }.sort_by! { |v| v["name"] }
@resource_block = generate_resource_block(resource, @properties)
@property_list = friendly_properly_list(@properties)
+ @examples = data["examples"]
- t = ERB.new(template)
+ t = ERB.new(template, nil, '-')
File.open("docs_site/resource_#{@name}.rst", "w") do |f|
f.write t.result(binding)
end