summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2016-03-26 21:16:28 -0700
committerTim Smith <tsmith84@gmail.com>2016-03-26 21:16:28 -0700
commit0bc3b1da2dfce675ce9f7ef71f73cd67e2312f32 (patch)
tree0a7b2193e0d8179cab792315ee8deb437475a9d9
parent72fa1edf8b969aaf64d8b5af551447a83bf0da25 (diff)
downloadchef-0bc3b1da2dfce675ce9f7ef71f73cd67e2312f32.tar.gz
Create better docs with knife cookbook create
Update knife cookbook create to create better markdown and include several segments in the readme to match what we've been writing in our community cookbooks
-rw-r--r--lib/chef/knife/cookbook_create.rb54
1 files changed, 32 insertions, 22 deletions
diff --git a/lib/chef/knife/cookbook_create.rb b/lib/chef/knife/cookbook_create.rb
index 1e19535fbf..950de380f8 100644
--- a/lib/chef/knife/cookbook_create.rb
+++ b/lib/chef/knife/cookbook_create.rb
@@ -185,13 +185,11 @@ EOH
unless File.exists?(File.join(dir, cookbook_name, "CHANGELOG.md"))
open(File.join(dir, cookbook_name, "CHANGELOG.md"), "w") do |file|
file.puts <<-EOH
-#{cookbook_name} CHANGELOG
-#{'=' * "#{cookbook_name} CHANGELOG".length}
+# #{cookbook_name} CHANGELOG
This file is used to list changes made in each version of the #{cookbook_name} cookbook.
-0.1.0
------
+## 0.1.0
- [your_name] - Initial release of #{cookbook_name}
- - -
@@ -205,7 +203,7 @@ EOH
def create_readme(dir, cookbook_name, readme_format)
msg("** Creating README for cookbook: #{cookbook_name}")
- unless File.exists?(File.join(dir, cookbook_name, "README.#{readme_format}"))
+ unless File.exist?(File.join(dir, cookbook_name, "README.#{readme_format}"))
open(File.join(dir, cookbook_name, "README.#{readme_format}"), "w") do |file|
case readme_format
when "rdoc"
@@ -273,27 +271,37 @@ Authors: TODO: List authors
EOH
when "md", "mkd", "txt"
file.puts <<-EOH
-#{cookbook_name} Cookbook
-#{'=' * "#{cookbook_name} Cookbook".length}
+# #{cookbook_name} Cookbook
+
TODO: Enter the cookbook description here.
e.g.
This cookbook makes your favorite breakfast sandwich.
-Requirements
-------------
+## Requirements
+
TODO: List your cookbook requirements. Be sure to include any requirements this cookbook has on platforms, libraries, other cookbooks, packages, operating systems, etc.
e.g.
-#### packages
+### Platforms
+
+- SandwichOS
+
+### Chef
+
+- Chef 12.0 or later
+
+### Cookbooks
+
- `toaster` - #{cookbook_name} needs toaster to brown your bagel.
-Attributes
-----------
+## Attributes
+
TODO: List your cookbook attributes here.
e.g.
-#### #{cookbook_name}::default
+### #{cookbook_name}::default
+
<table>
<tr>
<th>Key</th>
@@ -309,9 +317,10 @@ e.g.
</tr>
</table>
-Usage
------
-#### #{cookbook_name}::default
+## Usage
+
+### #{cookbook_name}::default
+
TODO: Write usage instructions for each cookbook.
e.g.
@@ -326,8 +335,8 @@ Just include `#{cookbook_name}` in your node's `run_list`:
}
```
-Contributing
-------------
+## Contributing
+
TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
e.g.
@@ -338,9 +347,10 @@ e.g.
5. Run the tests, ensuring they all pass
6. Submit a Pull Request using Github
-License and Authors
--------------------
+## License and Authors
+
Authors: TODO: List authors
+
EOH
else
file.puts <<-EOH
@@ -415,9 +425,9 @@ EOH
"All rights reserved"
end
- unless File.exists?(File.join(dir, cookbook_name, "metadata.rb"))
+ unless File.exist?(File.join(dir, cookbook_name, "metadata.rb"))
open(File.join(dir, cookbook_name, "metadata.rb"), "w") do |file|
- if File.exists?(File.join(dir, cookbook_name, "README.#{readme_format}"))
+ if File.exist?(File.join(dir, cookbook_name, "README.#{readme_format}"))
long_description = "long_description IO.read(File.join(File.dirname(__FILE__), 'README.#{readme_format}'))"
end
file.puts <<-EOH