Skip to content
This repository was archived by the owner on Nov 1, 2017. It is now read-only.

Commit edd1e07

Browse files
committed
Merge pull request #1007 from lndbrg/master
Add support for generating JSON from documentation
2 parents 7222c65 + d76ed55 commit edd1e07

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ tmp
1919
crash.log
2020
npm-debug.log
2121
build.txt
22+
json-dump

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ Some actions return arrays. You can modify the JSON by passing a block:
9595
<%= json(:issue) { |hash| [hash] } %>
9696
```
9797

98+
There is also a rake task for generating json files from the sample responses in the documentation:
99+
100+
``` sh
101+
$ rake generate_json_from_sample_responses
102+
```
103+
104+
The generated files will end up in `json-dump/`.
105+
98106
### Terminal blocks
99107

100108
You can specify terminal blocks by using the `command-line` syntax highlighting.

Rakefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,13 @@ task :publish, [:no_commit_msg] => [:remove_tmp_dir, :remove_output_dir, :build]
9797
system 'git checkout master'
9898
end
9999
end
100+
101+
desc "Generate JSON from the sample responses"
102+
task :generate_json_from_responses
103+
Dir[File.join(File.dirname(__FILE__), 'lib', 'responses', '*.rb')].each { |file| load file }
104+
FileUtils.mkdir_p(File.join(File.dirname(__FILE__), 'json-dump'))
105+
GitHub::Resources::Responses.constants.each { |constant|
106+
File.open('json-dump/' + constant.to_s + '.json', 'w') { |file|
107+
file.write(JSON.pretty_generate(GitHub::Resources::Helpers.get_resource(constant)))
108+
}
109+
}

0 commit comments

Comments
 (0)