prmd 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTJiYjFkZjYwZTAxYWExOTJmYzAxMWZjYmJiNmQ1YzA3ZTdiMmY0Ng==
4
+ NmYyYTg0MjRlYWQwZjBlZjFlMGU2OTVjODUyODYyZDQxOTZjMDgyNA==
5
5
  data.tar.gz: !binary |-
6
- Y2RmMDI2NTIyNzQxZTk4NjcxZmZhYzU5NTM2NDdlNmM4YWZhMTE4Mg==
6
+ MjNiZDJhNzdhMDU1M2MyYTNjOTViODgxMGJkZTMyNGY2YTRhODcwMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTE2N2FhODUzYjgxY2Y0YjJmOGUwYzRkYTQwYmY0Nzg2NDJhNDdjM2JhZGYy
10
- ZjFjY2MxMGY5ZmNkYjM0OTVlMmUyNTYzMGJlYTdmYjk1MTczOTZiODI3ZjVh
11
- MWZlYTQ2OTg2MWRlNjg3Yjc4ZmU2MThkMGVjNTc2Yjg5ZGZmMTA=
9
+ ZmI5ZDU5ZTBkMGNmODQyYWNkYmY4Y2IxMTJlY2QxMGYwNTgyY2MwZDI0Njg0
10
+ OTczYTU2ZDI0ODBjZTJkNGIxMTQwYTUwNDdkNzA5ZmMzNjM5ZTgyNzlmYzEy
11
+ YjI3YmNiYjkxYzVlNmU3NDc1ZDQ1ZTMzZDliODZhZDcyNWI0NGU=
12
12
  data.tar.gz: !binary |-
13
- ZjIyMmNlZmI2NGJiMjY2OGE5NWM2ZTJmMzkxMzAyM2NjNTkyOWFmMDZiMTRk
14
- MWEwOWUwYmY0YjM3Mzk1N2FhNDE1YTdkYWJiNTY1NmUxMTE0NmQ4YjBiOTVm
15
- Mjk5NzNmODZiNTIwNWUzY2Q3MDIxMjM0ZTRmNTEyMDFjMWU0MWY=
13
+ OTEyYTllYzkzODRkYWM3ODQ2NGM0MTA1Y2UyMjRiNDA4ZjMxZDUzMzI3YTRj
14
+ MjQyYTc1NmMyMWJmZTY4MTMxMDQ0OWYxYjBlZTNkMmVhYjAyNGQ2Yzc1Njg4
15
+ NjcyZWZiMGM0MTZhODc4Y2U1ZWNjNTIzNjFhOTQ1NzI4ZTZlN2I=
@@ -0,0 +1,18 @@
1
+ ## Getting Involved
2
+
3
+ New contributors are always welcome, when it doubt please ask questions. We strive to be an open and welcoming community. Please be nice to one another.
4
+
5
+ ### Coding
6
+
7
+ * Pick a task:
8
+ * Offer feedback on open [pull requests](https://github.com/heroku/prmd/pulls).
9
+ * Review open [issues](https://github.com/heroku/prmd/issues) for things to help on.
10
+ * [Create an issue](https://github.com/heroku/prmd/issues/new) to start a discussion on additions or features.
11
+ * Fork the project, add your changes and tests to cover them in a topic branch.
12
+ * Commit your changes and rebase against `heroku/prmd` to ensure everything is up to date.
13
+ * [Submit a pull request](https://github.com/heroku/prmd/compare/).
14
+
15
+ ### Non-Coding
16
+
17
+ * Offer feedback on open [issues](https://github.com/heroku/prmd/issues).
18
+ * Organize or volunteer at events.
@@ -1,6 +1,8 @@
1
1
  * Brandur <brandur@mutelight.org>
2
2
  * Chris Continanza <christopher.continanza@gmail.com>
3
+ * Dane Harrigan <dane.harrigan@gmail.com>
3
4
  * Mark McGranaghan <mmcgrana@gmail.com>
5
+ * Olivier Lance <olance@users.noreply.github.com>
4
6
  * Timothée Peignier <timothee.peignier@tryphon.org>
5
7
  * Wesley Beary <geemus+github@gmail.com>
6
8
  * geemus <geemus@gmail.com>
@@ -1,21 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- prmd (0.0.1)
5
- erubis
4
+ prmd (0.1.0)
5
+ erubis (~> 2.7)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  erubis (2.7.0)
11
- minitest (4.7.5)
12
- rake (10.1.0)
11
+ minitest (5.3.2)
12
+ rake (10.2.2)
13
13
 
14
14
  PLATFORMS
15
15
  ruby
16
16
 
17
17
  DEPENDENCIES
18
18
  bundler (~> 1.3)
19
- minitest
19
+ minitest (~> 5.3)
20
20
  prmd!
21
- rake
21
+ rake (~> 10.2)
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Prmd
2
2
 
3
3
  JSON Schema tooling: scaffold, verify, and generate documentation
4
- against JSON Schema documents.
4
+ from JSON Schema documents.
5
5
 
6
6
 
7
7
  ## Introduction
@@ -11,76 +11,100 @@ an API. prmd provides tools for bootstrapping a description like this,
11
11
  verifying its completeness, and generating documentation from the
12
12
  specification.
13
13
 
14
- The JSON Schema usage conventions expected by prmd are described in
15
- [/docs/schemata.md](/docs/schemata.md).
16
-
17
14
  To learn more about JSON Schema in general, start with
18
15
  [this excellent guide](http://spacetelescope.github.io/understanding-json-schema/)
19
16
  and supplement with the [specification](http://json-schema.org/documentation.html).
17
+ The JSON Schema usage conventions expected by prmd specifically are
18
+ described in [/docs/schemata.md](/docs/schemata.md).
20
19
 
21
20
  ## Installation
22
21
 
23
- Add this line to your application's Gemfile:
22
+ Install the command-line tool with:
24
23
 
25
- ```ruby
26
- gem 'prmd'
24
+ ```console
25
+ $ gem install prmd
27
26
  ```
28
27
 
29
- And then execute:
28
+ If you're using prmd within a Ruby project, you may want to add it
29
+ to the application's Gemfile:
30
30
 
31
- ```console
32
- $ bundle
31
+ ```ruby
32
+ gem 'prmd'
33
33
  ```
34
34
 
35
- Or install it yourself as:
36
-
37
35
  ```console
38
- $ gem install prmd
36
+ $ bundle install
39
37
  ```
40
38
 
41
39
  ## Usage
42
40
 
43
- Combine takes the path to a schema file or directory of schema files and
44
- combines them on to stdout. If -m or --meta is supplied, it will override
45
- defaults/metadata:
41
+ Prmd provides four main commands:
46
42
 
47
- ```console
48
- $ prmd combine <file or directory>
49
- ```
43
+ * `init`: Scaffold resource schemata
44
+ * `combine`: Combine schemata and metadata into single schema
45
+ * `verify`: Verify a schema
46
+ * `doc`: Generate documentation from a schema
50
47
 
51
- Doc takes the path to a combined schema and outputs documentation to stdout.
52
- If -m or --meta is supplied, it will override defaults/metadata:
48
+ Here's an example of using these commands in a typical workflow:
53
49
 
54
50
  ```console
55
- $ prmd doc <combined schema>
51
+ # Fill out the resource schemata
52
+ $ mkdir -p schemata
53
+ $ prmd init app > schemata/app.json
54
+ $ prmd init user > schemata/user.json
55
+ $ vim schemata/{app,user}.json # edit scaffolded files
56
+
57
+ # Provide top-level metadata
58
+ $ cat <<EOF > meta.json
59
+ {
60
+ "description": "Hello world prmd API",
61
+ "id": "hello-prmd",
62
+ "links": [{
63
+ "href": "https://api.hello.com",
64
+ "rel": "self"
65
+ }],
66
+ "title": "Hello Prmd"
67
+ }
68
+ EOF
69
+
70
+ # Combine into a single schema
71
+ $ prmd combine --meta meta.json schemata/ > schema.json
72
+
73
+ # Check it’s all good
74
+ $ prmd verify schema.json
75
+
76
+ # Build docs
77
+ $ prmd doc schema.json > schema.md
56
78
  ```
57
79
 
58
- You can also prepend files to the documention with -p or --prepend:
80
+ Typically you'll want to prepend header and overview information to
81
+ your API documentation. You can do this with the `--prepend` flag:
59
82
 
60
83
  ```console
61
- $ prmd doc -p header.md,overview.md <directory or schema>
84
+ $ prmd doc schema.json --prepend overview.md > schema.md
62
85
  ```
63
86
 
64
- Init optionally takes a resource as it's first argument and generates a
65
- new schema file to stdout (generically or using the resource name
66
- provided). If -m or --meta is supplied, it will override
67
- defaults/metadata:
87
+ You can also chain commands together as needed, e.g.:
68
88
 
69
89
  ```console
70
- $ prmd init
71
- $ prmd init <resource name>
90
+ $ prmd combine --meta meta.json schemata/ | prmd verify | prmd doc --prepend overview.md > schema.md
72
91
  ```
73
92
 
74
- Verify takes a path to a combined schema and warns about missing attributes.
93
+ See `prmd <command> --help` for additional usage details.
75
94
 
76
- ```console
77
- $ prmd verify <combined schema>
78
- ```
95
+ ## File Layout
79
96
 
80
- You can also chain commands as needed:
97
+ We suggest the following file layout for JSON schema related files:
81
98
 
82
- ```console
83
- $ prmd combine <directory> | prmd verify | prmd doc > schema.md
99
+ ```
100
+ /docs (top-level directory for project documentation)
101
+ /schema (API schema documentation)
102
+ /schemata
103
+ /{resource.json} (individual resource schema)
104
+ /meta.json (overall API metadata)
105
+ /overview.md (preamble for generated API docs)
106
+ /schema.json (complete generated JSON schema file)
107
+ /schema.md (complete generated API documentation file)
84
108
  ```
85
109
 
86
110
  ## Contributing
data/bin/prmd CHANGED
@@ -19,9 +19,6 @@ commands = {
19
19
  end,
20
20
  init: OptionParser.new do |opts|
21
21
  opts.banner = "prmd init [options] <resource name>"
22
- opts.on("-m", "--meta meta.json", "Set defaults for schemata") do |m|
23
- options[:meta] = m
24
- end
25
22
  end,
26
23
  verify: OptionParser.new do |opts|
27
24
  opts.banner = "prmd verify [options] <combined schema>"
@@ -10,10 +10,6 @@ module Prmd
10
10
  'type' => ['object']
11
11
  }
12
12
 
13
- if options[:meta] && File.exists?(options[:meta])
14
- data.merge!(JSON.parse(File.read(options[:meta])))
15
- end
16
-
17
13
  schema = Prmd::Schema.new(data)
18
14
 
19
15
  if resource
@@ -21,7 +17,7 @@ module Prmd
21
17
  parent, resource = resource.split('/')
22
18
  end
23
19
  schema['id'] = "schemata/#{resource}"
24
- schema['title'] = "#{schema['title']} - #{resource[0...1].upcase}#{resource[1..-1]}"
20
+ schema['title'] = "FIXME - #{resource[0...1].upcase}#{resource[1..-1]}"
25
21
  schema['definitions'] = {
26
22
  "created_at" => {
27
23
  "description" => "when #{resource} was created",
@@ -1,3 +1,3 @@
1
1
  module Prmd
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -64,6 +64,7 @@ end -%>
64
64
  data = {}
65
65
  if link['schema']['properties']
66
66
  link['schema']['properties'].each do |key, value|
67
+ _, value = schema.dereference(value)
67
68
  if value.has_key?('anyOf')
68
69
  id_ref = value['anyOf'].detect {|ref| ref['$ref'].split('/').last == 'id'}
69
70
  data[key] = schema.dereference(id_ref).last['example']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prmd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - geemus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-10 00:00:00.000000000 Z
11
+ date: 2014-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubis
@@ -76,6 +76,7 @@ extra_rdoc_files: []
76
76
  files:
77
77
  - .gitignore
78
78
  - .travis.yml
79
+ - CONTRIBUTING.md
79
80
  - CONTRIBUTORS.md
80
81
  - Gemfile
81
82
  - Gemfile.lock