Skip to content

Commit

Permalink
Version 0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchristie committed Dec 2, 2016
1 parent 89986f6 commit 13504a6
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 9 deletions.
25 changes: 25 additions & 0 deletions README.md
Expand Up @@ -2,7 +2,32 @@

An API Documentation generator.

* **Code sample generation** - Automatic code samples for Python, Javascript, and the command line.
* **Schema support** - Currently supports [Swagger][swagger], [RAML][raml], and [JSON HyperSchema][jsonhyperschema].
* **Themes** - Currently includes the [Slate][slate] API documentation theme.
Additional themes and support for theme customization is planned.

## Swagger example

The following will build API documentation for the Swagger "PetStore" example API.

$ pip install coredocs
$ pip install openapi-codec
$ coredocs build http://petstore.swagger.io/v2/swagger.json --format openapi

![Swagger Screenshot](screenshots/swagger.png)

## RAML example

The following will build API documentation for the Spotify API, based on their RAML schema.

$ pip install coredocs
$ pip install raml-codec
$ coredocs build https://raw.githubusercontent.com/spotify/web-api/master/specifications/raml/api.raml --format raml

![RAML Screenshot](screenshots/raml.png)

[swagger]: http://swagger.io/
[raml]: http://raml.org/
[jsonhyperschema]: http://json-schema.org/latest/json-schema-hypermedia.html
[slate]: https://github.com/lord/slate
2 changes: 1 addition & 1 deletion coredocs/__init__.py
@@ -1 +1 @@
__version__ = '0.0.4'
__version__ = '0.0.5'
4 changes: 4 additions & 0 deletions coredocs/templates/coredocs/document.html
Expand Up @@ -5,3 +5,7 @@ <h1 id="document-title">{{ document.title }}</h1>
{% for section_key, section in get_sections(document) %}
{% include "coredocs/section.html" %}
{% endfor %}

{% for link_key, link in get_links(document) %}
{% include "coredocs/link.html" %}
{% endfor %}
2 changes: 1 addition & 1 deletion coredocs/templates/coredocs/languages/javascript.html
Expand Up @@ -8,7 +8,7 @@
})

// Interact with the API endpoint
var action = ["{{ section_key }}", "{{ link_key }}"]
var action = [{% if section_key %}"{{ section_key }}", {% endif %}"{{ link_key }}"]
{% if link.fields %}var params = {
{% for field in link.fields %} {{ field.name }}: ...{% if not loop.last %},{% endif %}
{% endfor %}}
Expand Down
2 changes: 1 addition & 1 deletion coredocs/templates/coredocs/languages/python.html
Expand Up @@ -5,7 +5,7 @@
document = client.get("{{ schema_url }}"{% if schema_format %}, format="{{ schema_format }}"{% endif %})

# Interact with the API endpoint
action = ["{{ section_key }}", "{{ link_key }}"]
action = [{% if section_key %}"{{ section_key }}", {% endif %}"{{ link_key }}"]
{% if link.fields %}params = {
{% for field in link.fields %} "{{ field.name }}": ...{% if not loop.last %},{% endif %}
{% endfor %}}
Expand Down
2 changes: 1 addition & 1 deletion coredocs/templates/coredocs/languages/shell.html
Expand Up @@ -2,4 +2,4 @@
$ coreapi get {{ schema_url }}{% if schema_format %} --format {{ schema_format }}{% endif %}

# Interact with the API endpoint
$ coreapi action {{ section_key }} {{ link_key }}{% for field in link.fields %} -p {{ field.name }}=...{% endfor %}{% endhighlight %}</code></pre>
$ coreapi action {% if section_key %}{{ section_key }} {% endif %}{{ link_key }}{% for field in link.fields %} -p {{ field.name }}=...{% endfor %}{% endhighlight %}</code></pre>
10 changes: 5 additions & 5 deletions coredocs/templates/coredocs/link.html
Expand Up @@ -20,7 +20,7 @@ <h3>Path Parameters</h3>
</thead>
<tbody>
{% for field in get_fields('path', link ) %}
<tr><td><code>{{ field.name }}</code>{% if field.required %} <strong>required</strong>{% endif %}</td><td>{% if field.description %}{{ field.description }}{% endif %}</td></tr>
<tr><td class="parameter-name"><code>{{ field.name }}</code>{% if field.required %} <strong>required</strong>{% endif %}</td><td>{% if field.description %}{{ field.description }}{% endif %}</td></tr>
{% endfor %}
</tbody>
</table>
Expand All @@ -34,7 +34,7 @@ <h3>Query Parameters</h3>
</thead>
<tbody>
{% for field in get_fields('query', link ) %}
<tr><td><code>{{ field.name }}</code>{% if field.required %} <strong>required</strong>{% endif %}</td><td>{% if field.description %}{{ field.description }}{% endif %}</td></tr>
<tr><td class="parameter-name"><code>{{ field.name }}</code>{% if field.required %} <strong>required</strong>{% endif %}</td><td>{% if field.description %}{{ field.description }}{% endif %}</td></tr>
{% endfor %}
</tbody>
</table>
Expand All @@ -48,7 +48,7 @@ <h3>Header Parameters</h3>
</thead>
<tbody>
{% for field in get_fields('header', link ) %}
<tr><td><code>{{ field.name }}</code>{% if field.required %} <strong>required</strong>{% endif %}</td><td>{% if field.description %}{{ field.description }}{% endif %}</td></tr>
<tr><td class="parameter-name"><code>{{ field.name }}</code>{% if field.required %} <strong>required</strong>{% endif %}</td><td>{% if field.description %}{{ field.description }}{% endif %}</td></tr>
{% endfor %}
</tbody>
</table>
Expand All @@ -62,7 +62,7 @@ <h3>Request Body</h3>
</thead>
<tbody>
{% for field in get_fields('body', link ) %}
<tr><td><code>{{ field.name }}</code>{% if field.required %} <strong>required</strong>{% endif %}</td><td>{% if field.description %}{{ field.description }}{% endif %}</td></tr>
<tr><td class="parameter-name"><code>{{ field.name }}</code>{% if field.required %} <strong>required</strong>{% endif %}</td><td>{% if field.description %}{{ field.description }}{% endif %}</td></tr>
{% endfor %}
</tbody>
</table>
Expand All @@ -75,7 +75,7 @@ <h3>Request Body</h3>
</thead>
<tbody>
{% for field in get_fields('form', link ) %}
<tr><td><code>{{ field.name }}</code>{% if field.required %} <strong>required</strong>{% endif %}</td><td>{% if field.description %}{{ field.description }}{% endif %}</td></tr>
<tr><td class="parameter-name"><code>{{ field.name }}</code>{% if field.required %} <strong>required</strong>{% endif %}</td><td>{% if field.description %}{{ field.description }}{% endif %}</td></tr>
{% endfor %}
</tbody>
</table>
Expand Down
1 change: 1 addition & 0 deletions coredocs/templates/slate/index.html
Expand Up @@ -11,6 +11,7 @@
<style>
table.parameters strong {color: orange}
table.parameters code {background-color: transparent}
td.parameter-name {white-space: nowrap}
</style>
<style>{{ code_style }}</style>
</head>
Expand Down
Binary file added screenshots/raml.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/swagger.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 13504a6

Please sign in to comment.