[asterisk-commits] dlee: branch dlee/ari-event-remodel2 r392396 - /team/dlee/ari-event-remodel2/...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jun 20 23:36:46 CDT 2013
Author: dlee
Date: Thu Jun 20 23:36:44 2013
New Revision: 392396
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392396
Log:
Wiki cleanups
Modified:
team/dlee/ari-event-remodel2/rest-api-templates/api.wiki.mustache
team/dlee/ari-event-remodel2/rest-api-templates/asterisk_processor.py
team/dlee/ari-event-remodel2/rest-api-templates/models.wiki.mustache
team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py
team/dlee/ari-event-remodel2/rest-api-templates/type_link.mustache
Modified: team/dlee/ari-event-remodel2/rest-api-templates/api.wiki.mustache
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/rest-api-templates/api.wiki.mustache?view=diff&rev=392396&r1=392395&r2=392396
==============================================================================
--- team/dlee/ari-event-remodel2/rest-api-templates/api.wiki.mustache (original)
+++ team/dlee/ari-event-remodel2/rest-api-templates/api.wiki.mustache Thu Jun 20 23:36:44 2013
@@ -1,18 +1,17 @@
{{#api_declaration}}
-
-h1. {{name}}
+h1. {{name_title}}
|| Method || Path || Return Model || Summary ||
{{#apis}}
{{#operations}}
-| {{http_method}} | [{{path}}|#{{nickname}}] | {{#response_class}}{{> type_link}}{{/response_class}} | {{summary}} |
+| {{http_method}} | [{{wiki_path}}|#{{nickname}}] | {{#response_class}}{{#is_primitive}}{{name}}{{/is_primitive}}{{^is_primitive}}[{{wiki_name}}|{{wiki_prefix}} REST Data Models#{{singular_name}}]{{/is_primitive}}{{/response_class}} | {{summary}} |
{{/operations}}
{{/apis}}
{{#apis}}
{{#operations}}
{anchor:{{nickname}}}
-h2. {{http_method}} {{path}}
+h2. {{http_method}} {{wiki_path}}
{{{summary}}}{{#notes}} {{{notes}}}{{/notes}}
{{#has_path_parameters}}
@@ -26,14 +25,14 @@
h3. Query parameters
{{#query_parameters}}
-* {{name}}: {{data_type}}{{#default_value}} = {{default_value}}{{/default_value}} - {{description}}
+* {{name}}: {{data_type}}{{#default_value}} = {{default_value}}{{/default_value}} -{{#required}} *(required)*{{/required}} {{description}}
{{/query_parameters}}
{{/has_query_parameters}}
{{#has_header_parameters}}
h3. Header parameters
{{#header_parameters}}
-* {{name}}: {{data_type}}{{#default_value}} = {{default_value}}{{/default_value}} - {{description}}
+* {{name}}: {{data_type}}{{#default_value}} = {{default_value}}{{/default_value}} -{{#required}} *(required)*{{/required}} {{description}}
{{/header_parameters}}
{{/has_header_parameters}}
{{#has_error_responses}}
Modified: team/dlee/ari-event-remodel2/rest-api-templates/asterisk_processor.py
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/rest-api-templates/asterisk_processor.py?view=diff&rev=392396&r1=392395&r2=392396
==============================================================================
--- team/dlee/ari-event-remodel2/rest-api-templates/asterisk_processor.py (original)
+++ team/dlee/ari-event-remodel2/rest-api-templates/asterisk_processor.py Thu Jun 20 23:36:44 2013
@@ -33,6 +33,14 @@
if name.startswith('{') and name.endswith('}'):
return name[1:-1]
return name
+
+
+def wikify(str):
+ """Escapes a string for the wiki.
+
+ @param str: String to escape
+ """
+ return re.sub(r'([{}\[\]])', r'\\\1', str)
def snakify(name):
@@ -134,7 +142,7 @@
def __init__(self, wiki_prefix):
self.wiki_prefix = wiki_prefix
- def process_api(self, resource_api, context):
+ def process_resource_api(self, resource_api, context):
resource_api.wiki_prefix = self.wiki_prefix
# Derive a resource name from the API declaration's filename
resource_api.name = re.sub('\..*', '',
@@ -163,6 +171,9 @@
"API declaration name should match", context)
resource_api.root_full_name = resource_api.root_path.full_name
+ def process_api(self, api, context):
+ api.wiki_path = wikify(api.path)
+
def process_operation(self, operation, context):
# Nicknames are camelcase, Asterisk coding is snake case
operation.c_nickname = snakify(operation.nickname)
@@ -199,3 +210,4 @@
def process_type(self, swagger_type, context):
swagger_type.c_name = snakify(swagger_type.name)
swagger_type.c_singular_name = snakify(swagger_type.singular_name)
+ swagger_type.wiki_name = wikify(swagger_type.name)
Modified: team/dlee/ari-event-remodel2/rest-api-templates/models.wiki.mustache
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/rest-api-templates/models.wiki.mustache?view=diff&rev=392396&r1=392395&r2=392396
==============================================================================
--- team/dlee/ari-event-remodel2/rest-api-templates/models.wiki.mustache (original)
+++ team/dlee/ari-event-remodel2/rest-api-templates/models.wiki.mustache Thu Jun 20 23:36:44 2013
@@ -14,7 +14,7 @@
{{{model_json}}}
{code}
{{#properties}}
-* {{name}}: {{#type}}{{> type_link}}{{/type}}{{^required}} _(optional)_{{/required}}{{#description}} - {{{description}}}{{/description}}
+* {{name}}: {{#type}}{{#is_primitive}}{{wiki_name}}{{/is_primitive}}{{^is_primitive}}[{{wiki_name}}|#{{singular_name}}]{{/is_primitive}}{{/type}}{{^required}} _(optional)_{{/required}}{{#description}} - {{{description}}}{{/description}}
{{/properties}}
{{/models}}
Modified: team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py?view=diff&rev=392396&r1=392395&r2=392396
==============================================================================
--- team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py (original)
+++ team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py Thu Jun 20 23:36:44 2013
@@ -128,10 +128,18 @@
fields to model objects for additional information to use in the
templates.
"""
- def process_api(self, resource_api, context):
+ def process_resource_api(self, resource_api, context):
"""Post process a ResourceApi object.
@param resource_api: ResourceApi object.
+ @param context: Current context in the API.
+ """
+ pass
+
+ def process_api(self, api, context):
+ """Post process an Api object.
+
+ @param api: Api object.
@param context: Current context in the API.
"""
pass
@@ -403,6 +411,7 @@
Operation().load(j, processor, context) for j in op_json]
self.has_websocket = \
filter(lambda op: op.is_websocket, self.operations) != []
+ processor.process_api(self, context)
return self
@@ -523,9 +532,10 @@
def subtypes(self):
"""Returns the full list of all subtypes.
"""
- return self.__subtypes + \
+ res = self.__subtypes + \
[subsubtypes for subtype in self.__subtypes \
for subsubtypes in subtype.subtypes()]
+ return sorted(res, key=lambda m: m.id)
def has_subtypes(self):
"""Returns True if type has any subtypes.
@@ -635,13 +645,13 @@
if not self.path or self.path[0] != '/':
raise SwaggerError("Path must start with /", context)
- processor.process_api(self, context)
+ processor.process_resource_api(self, context)
return self
def load_api_declaration(self, base_dir, processor):
self.file = (base_dir + self.path).replace('{format}', 'json')
self.api_declaration = ApiDeclaration().load_file(self.file, processor)
- processor.process_api(self, [self.file])
+ processor.process_resource_api(self, [self.file])
class ResourceListing(Stringify):
Modified: team/dlee/ari-event-remodel2/rest-api-templates/type_link.mustache
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/rest-api-templates/type_link.mustache?view=diff&rev=392396&r1=392395&r2=392396
==============================================================================
--- team/dlee/ari-event-remodel2/rest-api-templates/type_link.mustache (original)
+++ team/dlee/ari-event-remodel2/rest-api-templates/type_link.mustache Thu Jun 20 23:36:44 2013
@@ -18,4 +18,4 @@
{{!
* Snippet to emit a linked type for the wiki
}}
-{{#is_primitive}}{{name}}{{/is_primitive}}{{^is_primitive}}[{{name}}|{{wiki_prefix}} REST Data Models#{{singular_name}}]{{/is_primitive}}
+
More information about the asterisk-commits
mailing list