Skip to content

Commit

Permalink
adding code samples
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Hannaford committed Nov 24, 2015
1 parent a3e9a6c commit bde994a
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 31 deletions.
75 changes: 45 additions & 30 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion doc/api-docs/template/class.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% import _self as selfClass %}
{% from "macros.twig" import render_classes, breadcrumbs, namespace_link, class_link, property_link, method_link, hint_link %}
{% from "sub_param_macros.twig" import output_sub_param, iterate_sub_params, fill %}
{% from "sub_param_macros.twig" import output_sub_param, iterate_sub_params, fill, sub_param_example %}
{% block title %}{{ class.name }} | {{ parent() }}{% endblock %}
{% block body_class 'class' %}
{% block page_id 'class:' ~ (class.name|replace({'\\': '_'})) %}
Expand Down Expand Up @@ -304,6 +304,9 @@

{{ block('see') }}
{% endif %}

<h4>Example code</h4>
<pre class="php"><code class="php">{{ code_sample(method)|trim|raw }}</code></pre>
</div>
</div>
{% endblock %}
8 changes: 8 additions & 0 deletions doc/api-docs/template/css/opencloud.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,12 @@ table.params-table td {
.method-item h3 {
padding:10px !important;
margin-top:0 !important;
}
pre.php {
padding: 15px;
font-size: 14px;
border: none;
}
code.pre {
padding: 0;
}
3 changes: 3 additions & 0 deletions doc/api-docs/template/layout/base.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@
<script src="{{ path('js/bootstrap.min.js') }}"></script>
<script src="{{ path('js/typeahead.min.js') }}"></script>
<script src="{{ path('sami.js') }}"></script>

<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.9.1/styles/github.min.css">
<script src="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.9.1/highlight.min.js"></script>
{% endblock %}
1 change: 1 addition & 0 deletions doc/api-docs/template/layout/layout.twig
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,5 @@
<div id="footer">
Generated by <a href="http://sami.sensiolabs.org/">Sami, the API Documentation Generator</a>.
</div>
<script>hljs.initHighlightingOnLoad();</script>
{% endblock %}
20 changes: 20 additions & 0 deletions doc/api-docs/template/sub_param_macros.twig
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,23 @@
&nbsp;
{% endif %}
{%- endmacro %}

{% macro sub_param_example(sub_param, name) %}
{%- if sub_param.type == 'string' -%}
{%- verbatim -%}'{{%- endverbatim -%}{{- name -}}{%- verbatim -%}}'{%- endverbatim -%}
{%- elseif sub_param.type == 'bool' or sub_param.type == 'boolean' -%}
{{- 'true' -}}
{%- elseif sub_param.type == 'array' -%}
{% verbatim %}[{% endverbatim %}
{% for i in 1..2 %}
{{ _self.sub_param_example(sub_param.itemSchema, 'val' ~ i)|trim|raw }}{% verbatim %},{% endverbatim %}
{% endfor %}
{% verbatim %}]{% endverbatim %}
{%- elseif sub_param.type == 'object' -%}
{% verbatim %}[{% endverbatim %}
{% for propName, prop in sub_param.properties %}
{% verbatim %}'{% endverbatim %}{{- propName|trim -}}{%- verbatim -%}' => {%- endverbatim -%}{{- _self.sub_param_example(prop, propName)|trim|raw -}}{% verbatim %},{% endverbatim %}
{% endfor %}
{% verbatim %}]{% endverbatim %}
{%- endif -%}
{% endmacro %}

0 comments on commit bde994a

Please sign in to comment.