diff --git a/autoapi/base.py b/autoapi/base.py index 77b0a5d..512d07a 100644 --- a/autoapi/base.py +++ b/autoapi/base.py @@ -17,7 +17,7 @@ class AutoAPIBase(object): '{language}/{type}.rst'.format(language=self.language, type=self.type) ) ctx.update(**self.obj) - return template.render(ctx) + return template.render(**ctx) class UnknownType(AutoAPIBase): diff --git a/autoapi/dotnet.py b/autoapi/dotnet.py index e1177f8..439149b 100644 --- a/autoapi/dotnet.py +++ b/autoapi/dotnet.py @@ -28,10 +28,33 @@ class DotNetNamespace(DotNetBase): type = 'namespace' header = '=' - def render(self, **kwargs): - ret = super(DotNetNamespace, self).render(**kwargs) - # import ipdb; ipdb.set_trace() - return ret +class DotNetMethod(DotNetBase): + type = 'method' + header = '-' + +class DotNetProperty(DotNetBase): + type = 'property' + header = '-' + +class DotNetEnum(DotNetBase): + type = 'enum' + header = '-' + +class DotNetStruct(DotNetBase): + type = 'struct' + header = '-' + +class DotNetConstructor(DotNetBase): + type = 'constructor' + header = '-' + +class DotNetInterface(DotNetBase): + type = 'interface' + header = '-' + +class DotNetDelegate(DotNetBase): + type = 'delegate' + header = '-' class DotNetClass(object): diff --git a/autoapi/templates/base/base.rst b/autoapi/templates/base/base.rst index f17ff67..3f3900f 100644 --- a/autoapi/templates/base/base.rst +++ b/autoapi/templates/base/base.rst @@ -1,4 +1,11 @@ -{# Identention in this file is important #} +.. {{ type.lower() }}:: {{ name }} - (Generic Type -- {{ type }}) - .. {{ type.lower() }}:: {{ name }} + {% if summary %} + + {{ summary }} + + {% endif %} + + .. code-block:: csharp + + {{ syntax.content.CSharp }} diff --git a/autoapi/templates/dotnet/constructor.rst b/autoapi/templates/dotnet/constructor.rst new file mode 100644 index 0000000..1d37732 --- /dev/null +++ b/autoapi/templates/dotnet/constructor.rst @@ -0,0 +1,12 @@ +.. dn:{{ type.lower() }}:: {{ qualifiedName.CSharp }} + + {% if summary %} + + {% macro render() %}{{ summary }}{% endmacro %} + {{ render()|indent(4) }} + + {% endif %} + + .. code-block:: csharp + + {{ syntax.content.CSharp }} diff --git a/autoapi/templates/dotnet/delegate.rst b/autoapi/templates/dotnet/delegate.rst new file mode 100644 index 0000000..a017795 --- /dev/null +++ b/autoapi/templates/dotnet/delegate.rst @@ -0,0 +1,15 @@ +{{ name.CSharp }} +{{ underline }} + +.. dn:delegate:: {{ qualifiedName.CSharp }} + + {% if summary %} + + {% macro render() %}{{ summary }}{% endmacro %} + {{ render()|indent(4) }} + + {% endif %} + + .. code-block:: csharp + + {{ syntax.content.CSharp }} diff --git a/autoapi/templates/dotnet/enum.rst b/autoapi/templates/dotnet/enum.rst new file mode 100644 index 0000000..bde3683 --- /dev/null +++ b/autoapi/templates/dotnet/enum.rst @@ -0,0 +1,13 @@ +{{ name.CSharp }} +{{ underline }} + +.. dn:enumeration:: {{ qualifiedName.CSharp }} + + {% if summary %} + {% macro render() %}{{ summary }}{% endmacro %} + {{ render()|indent(4) }} + {% endif %} + + .. code-block:: csharp + + {{ syntax.content.CSharp }} diff --git a/autoapi/templates/dotnet/interface.rst b/autoapi/templates/dotnet/interface.rst new file mode 100644 index 0000000..2164602 --- /dev/null +++ b/autoapi/templates/dotnet/interface.rst @@ -0,0 +1,13 @@ +{{ name.CSharp }} +{{ underline }} + +.. dn:{{ type.lower() }}:: {{ qualifiedName.CSharp }} + + {% if summary %} + {% macro render() %}{{ summary }}{% endmacro %} + {{ render()|indent(4) }} + {% endif %} + + .. code-block:: csharp + + {{ syntax.content.CSharp }} diff --git a/autoapi/templates/dotnet/method.rst b/autoapi/templates/dotnet/method.rst new file mode 100644 index 0000000..53cf668 --- /dev/null +++ b/autoapi/templates/dotnet/method.rst @@ -0,0 +1,12 @@ +.. dn:{{ type.lower() }}:: {{ qualifiedName.CSharp }} + + {% if summary %} + + {% macro render() %}{{ summary }}{% endmacro %} + {{ render()|indent(4) }} + + {% endif %} + + .. code-block:: csharp + + {{ syntax.content.CSharp }} diff --git a/autoapi/templates/dotnet/methods.rst b/autoapi/templates/dotnet/methods.rst deleted file mode 100644 index 0581089..0000000 --- a/autoapi/templates/dotnet/methods.rst +++ /dev/null @@ -1,17 +0,0 @@ -{# Identention in this file is important #} - -{% if methods %} - -.. rubric:: Methods - -{% for item in methods %} - -.. method:: {{ item.qualifiedName.CSharp }} - -.. code-block:: csharp - - {{ item.syntax.content.CSharp }} - -{%- endfor %} - -{% endif %} diff --git a/autoapi/templates/dotnet/property.rst b/autoapi/templates/dotnet/property.rst new file mode 100644 index 0000000..53cf668 --- /dev/null +++ b/autoapi/templates/dotnet/property.rst @@ -0,0 +1,12 @@ +.. dn:{{ type.lower() }}:: {{ qualifiedName.CSharp }} + + {% if summary %} + + {% macro render() %}{{ summary }}{% endmacro %} + {{ render()|indent(4) }} + + {% endif %} + + .. code-block:: csharp + + {{ syntax.content.CSharp }} diff --git a/autoapi/templates/dotnet/struct.rst b/autoapi/templates/dotnet/struct.rst new file mode 100644 index 0000000..e808151 --- /dev/null +++ b/autoapi/templates/dotnet/struct.rst @@ -0,0 +1,15 @@ +{{ name.CSharp }} +{{ underline }} + +.. dn:structure:: {{ qualifiedName.CSharp }} + + {% if summary %} + + {% macro render() %}{{ summary }}{% endmacro %} + {{ render()|indent(4) }} + + {% endif %} + + .. code-block:: csharp + + {{ syntax.content.CSharp }} diff --git a/autoapi/utils.py b/autoapi/utils.py index a4745f3..ff5c360 100644 --- a/autoapi/utils.py +++ b/autoapi/utils.py @@ -1,5 +1,9 @@ from .base import UnknownType -from .dotnet import DotNetNamespace, DotNetClass +from .dotnet import ( + DotNetNamespace, DotNetClass, DotNetMethod, DotNetProperty, + DotNetEnum, DotNetConstructor, DotNetStruct, DotNetInterface, + DotNetDelegate + ) from .python import PythonModule, PythonClass, PythonFunction @@ -19,4 +23,18 @@ def classify(obj, obj_type): return DotNetClass(obj) if obj['type'] == 'Namespace': return DotNetNamespace(obj) + if obj['type'] == 'Property': + return DotNetProperty(obj) + if obj['type'] == 'Method': + return DotNetMethod(obj) + if obj['type'] == 'Enum': + return DotNetEnum(obj) + if obj['type'] == 'Constructor': + return DotNetConstructor(obj) + if obj['type'] == 'Struct': + return DotNetStruct(obj) + if obj['type'] == 'Interface': + return DotNetInterface(obj) + if obj['type'] == 'Delegate': + return DotNetDelegate(obj) return UnknownType(obj)