Skip to content

Commit 843866b

Browse files
committed
Merge branch 'master' of github.com:zipmark/rspec_api_documentation
2 parents 358c7fa + c2cee35 commit 843866b

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,48 @@ RspecApiDocumentation.configure do |config|
125125
end
126126
```
127127

128+
## Format
129+
130+
* **json**: Generates an index file and example files in JSON.
131+
* **html**: Generates an index file and example files in HTML.
132+
* **combined_text**: Generates a single file for each resource. Used by [Raddocs](http://github.com/smartlogic/raddocs) for command line docs.
133+
* **combined_json**: Generates a single file for all examples.
134+
* **json_iodocs**: Generates [I/O Docs](http://www.mashery.com/product/io-docs) style documentation.
135+
* **textile**: Generates an index file and example files in Textile.
136+
* **append_json**: Lets you selectively run specs without destroying current documentation. See section below.
137+
138+
### append_json
139+
140+
This format cannot be run with other formats as they will delete the entire documentation folder upon each run. This format appends new examples to the index file, and writes all run examples in the correct folder.
141+
142+
Below is a rake task that allows this format to be used easily.
143+
144+
```ruby
145+
RSpec::Core::RakeTask.new('docs:generate:append', :spec_file) do |t, task_args|
146+
if spec_file = task_args[:spec_file]
147+
ENV["DOC_FORMAT"] = "append_json"
148+
end
149+
t.pattern = spec_file || 'spec/acceptance/**/*_spec.rb'
150+
t.rspec_opts = ["--format RspecApiDocumentation::ApiFormatter"]
151+
end
152+
```
153+
154+
And in your `spec/spec_helper.rb`:
155+
156+
```ruby
157+
ENV["DOC_FORMAT"] ||= "json"
158+
159+
RspecApiDocumentation.configure do |config|
160+
config.format = ENV["DOC_FORMAT"]
161+
end
162+
```
163+
164+
```bash
165+
rake docs:generate:append[spec/acceptance/orders_spec.rb]
166+
```
167+
168+
This will update the current index's examples to include any in the `orders_spec.rb` file. Any examples inside will be rewritten.
169+
128170
## Filtering and Exclusion
129171
rspec_api_documentation lets you determine which examples get outputted into the final documentation.
130172
All filtering is done via the `:document` metadata key.

0 commit comments

Comments
 (0)