diff --git a/autoapi/dotnet.py b/autoapi/dotnet.py index 45d64ba..7ffedf6 100644 --- a/autoapi/dotnet.py +++ b/autoapi/dotnet.py @@ -23,10 +23,26 @@ class DotNetBase(AutoAPIBase): # Optional self.summary = obj.get('summary', '') - if 'syntax' in obj: - self.syntax = obj['syntax']['content']['CSharp'] - else: - self.syntax = '' + + # Syntax example and parameter list + syntax = obj.get('syntax', None) + self.example = '' + if syntax is not None: + # Code example + try: + self.example = syntax['content']['CSharp'] + except KeyError: + pass + + self.parameters = [] + for param in syntax.get('parameters', []): + if 'id' in param: + self.parameters.append({ + 'name': param.get('id'), + 'type': param.get('type', {}).get('id', None), + 'desc': param.get('description', '') + }) + self.children = obj.get('items', []) if self.children: self.item_map = defaultdict(list) diff --git a/autoapi/templates/dotnet/base_embed.rst b/autoapi/templates/dotnet/base_embed.rst index 54d85bb..d9307c6 100644 --- a/autoapi/templates/dotnet/base_embed.rst +++ b/autoapi/templates/dotnet/base_embed.rst @@ -1,12 +1,19 @@ .. dn:{{ type.lower() }}:: {{ name }} - {% if summary %} + {% if summary %} {% macro render() %}{{ summary }}{% endmacro %} {{ render()|indent(4) }} - {% endif %} + {% endif %} - .. code-block:: csharp + {%- for param in parameters %} + :param {{ param.name }}: {{ param.desc }} + {%- if param.type %} + :type {{ param.name }}: {{ param.type }} + {%- endif %} + {%- endfor %} - {{ syntax }} + .. code-block:: csharp + + {{ example }}