neo_doxygen: Add an option to remove the `def` keyword of Python.
authorJean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Wed, 17 Dec 2014 20:18:24 +0000 (15:18 -0500)
committerJean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Fri, 19 Dec 2014 16:32:29 +0000 (11:32 -0500)
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

contrib/neo_doxygen/src/doxml/language_specific.nit
contrib/neo_doxygen/src/neo_doxygen.nit
tests/neo_doxygen_dump.args
tests/sav/neo_doxygen_dump.res
tests/sav/neo_doxygen_dump_args9.res [new file with mode: 0644]

index fc03b0f..9566f9e 100644 (file)
@@ -179,3 +179,14 @@ class JavaSource
                super
        end
 end
+
+# Importation logics for Python.
+class PythonSource
+       super SourceLanguage
+
+       redef fun apply_member_type(member, type_text) do
+               # Doxygen may forgot to remove the `def` keyword on methods.
+               extract_keyword(type_text, "def")
+               super
+       end
+end
index 46c6be2..431809c 100644 (file)
@@ -149,6 +149,7 @@ class NeoDoxygenCommand
        init do
                sources["any"] = new DefaultSource
                sources["java"] = new JavaSource
+               sources["python"] = new PythonSource
 
                var prefix = new OptionText("""
 {{{"NAME".bold}}}
@@ -185,7 +186,7 @@ class NeoDoxygenCommand
 
                var keys = new Array[String].from(sources.keys)
                opt_src_lang = new OptionEnum(keys,
-                               "The programming language to assume when processing chunk in the declarations left as-is by Doxygen. Use `any` (the default) to disable any language-specific processing.",
+                               "The programming language to assume when processing chunks in the declarations left as-is by Doxygen. Use `any` (the default) to disable any language-specific processing.",
                                keys.index_of("any"), "--src-lang")
                option_context.add_option(opt_src_lang)
        end
@@ -249,8 +250,8 @@ end
 
 # Add handling of multi-line descriptions.
 #
-# Note: The algorithm is naive and do not handle internationalisation and
-# escape sequences.
+# Note: The algorithm is naive and do not handle internationalisation,
+# multi-byte characters and control characters.
 redef class Option
 
        redef fun pretty(off) do
index abd29fc..21f45e7 100644 (file)
@@ -6,3 +6,4 @@
 --src-lang java -- root-namespace ../contrib/neo_doxygen/tests/root-namespace/xml
 --src-lang java -- inner-class ../contrib/neo_doxygen/tests/inner-class/xml
 -- python-def ../contrib/neo_doxygen/tests/python-def/xml
+--src-lang python -- python-def ../contrib/neo_doxygen/tests/python-def/xml
index e043e01..74384a4 100644 (file)
@@ -25,7 +25,7 @@
 
   -h, --help   Show the help (this page).
 
-  --src-lang   The programming language to assume when processing chunk in the
+  --src-lang   The programming language to assume when processing chunks in the
                declarations left as-is by Doxygen. Use `any` (the default) to
-               disable any language-specific processing. <any, java>
+               disable any language-specific processing. <any, java, python>
 
diff --git a/tests/sav/neo_doxygen_dump_args9.res b/tests/sav/neo_doxygen_dump_args9.res
new file mode 100644 (file)
index 0000000..1c9cc04
--- /dev/null
@@ -0,0 +1,391 @@
+Reading ../contrib/neo_doxygen/tests/python-def/xml... Done.
+3 files read.
+Linking nodes...\e[s \e[u\e[J Done.
+Saving 10 nodes...
+---===DONE===---
+Saving 17 edges...
+Edge
+=type=4:ROOT
+=properties=JsonObject(0):
+{}
+----
+=from=Node
+=labels=Array(3):
+10:python-def
+7:MEntity
+8:MProject
+=properties=JsonObject(1):
+{"name":"python-def"}
+----
+=to=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MGroup
+=properties=JsonObject(1):
+{"name":"python-def"}
+
+
+Edge
+=type=7:PROJECT
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MGroup
+=properties=JsonObject(1):
+{"name":"python-def"}
+----
+=to=Node
+=labels=Array(3):
+10:python-def
+7:MEntity
+8:MProject
+=properties=JsonObject(1):
+{"name":"python-def"}
+
+
+Edge
+=type=6:PARENT
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#12:namespacefoo
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MGroup
+=properties=JsonObject(4):
+{"kind":"namespace","visibility":"","name":"foo","location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1"}
+----
+=to=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MGroup
+=properties=JsonObject(1):
+{"name":"python-def"}
+
+
+Edge
+=type=5:NESTS
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MGroup
+=properties=JsonObject(1):
+{"name":"python-def"}
+----
+=to=Entity#12:namespacefoo
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MGroup
+=properties=JsonObject(4):
+{"kind":"namespace","visibility":"","name":"foo","location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1"}
+
+
+Edge
+=type=8:DECLARES
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#12:namespacefoo
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MGroup
+=properties=JsonObject(4):
+{"kind":"namespace","visibility":"","name":"foo","location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1"}
+----
+=to=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+7:MModule
+=properties=JsonObject(2):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1","name":"foo"}
+
+
+Edge
+=type=10:INTRODUCES
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+7:MModule
+=properties=JsonObject(2):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1","name":"foo"}
+----
+=to=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MClass
+=properties=JsonObject(4):
+{"kind":"class","visibility":"public","name":"(self)","location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1"}
+
+
+Edge
+=type=7:DEFINES
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+7:MModule
+=properties=JsonObject(2):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1","name":"foo"}
+----
+=to=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+9:MClassDef
+=properties=JsonObject(3):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1","is_intro":true,"name":"(self)"}
+
+
+Edge
+=type=7:DEFINES
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#47:namespacefoo_1aab1e88a2212b202c20f3c9bd799a1ad4
+=labels=Array(4):
+10:python-def
+7:MEntity
+8:MPropDef
+10:MMethodDef
+=properties=JsonObject(8):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:16,1--20,1","is_intern":false,"is_extern":false,"is_abstract":false,"visibility":"public","name":"bar","mdoc":["A bar function in the foo namespace.","By default, Doxygen recognizes anything in the docstrings as verbatim\ndetailed description."],"is_intro":true}
+----
+=to=Entity#0:
+=labels=Array(4):
+10:python-def
+7:MEntity
+9:MProperty
+7:MMethod
+=properties=JsonObject(3):
+{"visibility":"public","is_init":false,"name":"bar"}
+
+
+Edge
+=type=9:SIGNATURE
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#47:namespacefoo_1aab1e88a2212b202c20f3c9bd799a1ad4
+=labels=Array(4):
+10:python-def
+7:MEntity
+8:MPropDef
+10:MMethodDef
+=properties=JsonObject(8):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:16,1--20,1","is_intern":false,"is_extern":false,"is_abstract":false,"visibility":"public","name":"bar","mdoc":["A bar function in the foo namespace.","By default, Doxygen recognizes anything in the docstrings as verbatim\ndetailed description."],"is_intro":true}
+----
+=to=Entity#0:
+=labels=Array(4):
+10:python-def
+7:MEntity
+5:MType
+10:MSignature
+=properties=JsonObject(0):
+{}
+
+
+Edge
+=type=7:PROJECT
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#12:namespacefoo
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MGroup
+=properties=JsonObject(4):
+{"kind":"namespace","visibility":"","name":"foo","location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1"}
+----
+=to=Node
+=labels=Array(3):
+10:python-def
+7:MEntity
+8:MProject
+=properties=JsonObject(1):
+{"name":"python-def"}
+
+
+Edge
+=type=9:CLASSTYPE
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MClass
+=properties=JsonObject(4):
+{"kind":"class","visibility":"public","name":"(self)","location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1"}
+----
+=to=Entity#0:
+=labels=Array(4):
+10:python-def
+7:MEntity
+5:MType
+10:MClassType
+=properties=JsonObject(1):
+{"name":"(self)"}
+
+
+Edge
+=type=5:CLASS
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(4):
+10:python-def
+7:MEntity
+5:MType
+10:MClassType
+=properties=JsonObject(1):
+{"name":"(self)"}
+----
+=to=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MClass
+=properties=JsonObject(4):
+{"kind":"class","visibility":"public","name":"(self)","location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1"}
+
+
+Edge
+=type=9:BOUNDTYPE
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+9:MClassDef
+=properties=JsonObject(3):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1","is_intro":true,"name":"(self)"}
+----
+=to=Entity#0:
+=labels=Array(4):
+10:python-def
+7:MEntity
+5:MType
+10:MClassType
+=properties=JsonObject(1):
+{"name":"(self)"}
+
+
+Edge
+=type=6:MCLASS
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+9:MClassDef
+=properties=JsonObject(3):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1","is_intro":true,"name":"(self)"}
+----
+=to=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+6:MClass
+=properties=JsonObject(4):
+{"kind":"class","visibility":"public","name":"(self)","location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1"}
+
+
+Edge
+=type=10:INTRODUCES
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+9:MClassDef
+=properties=JsonObject(3):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1","is_intro":true,"name":"(self)"}
+----
+=to=Entity#0:
+=labels=Array(4):
+10:python-def
+7:MEntity
+9:MProperty
+7:MMethod
+=properties=JsonObject(3):
+{"visibility":"public","is_init":false,"name":"bar"}
+
+
+Edge
+=type=14:INTRO_CLASSDEF
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(4):
+10:python-def
+7:MEntity
+9:MProperty
+7:MMethod
+=properties=JsonObject(3):
+{"visibility":"public","is_init":false,"name":"bar"}
+----
+=to=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+9:MClassDef
+=properties=JsonObject(3):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1","is_intro":true,"name":"(self)"}
+
+
+Edge
+=type=8:DECLARES
+=properties=JsonObject(0):
+{}
+----
+=from=Entity#0:
+=labels=Array(3):
+10:python-def
+7:MEntity
+9:MClassDef
+=properties=JsonObject(3):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:1,1--1,1","is_intro":true,"name":"(self)"}
+----
+=to=Entity#47:namespacefoo_1aab1e88a2212b202c20f3c9bd799a1ad4
+=labels=Array(4):
+10:python-def
+7:MEntity
+8:MPropDef
+10:MMethodDef
+=properties=JsonObject(8):
+{"location":"%SOURCE_DIRECTORY%\/foo.py:16,1--20,1","is_intern":false,"is_extern":false,"is_abstract":false,"visibility":"public","name":"bar","mdoc":["A bar function in the foo namespace.","By default, Doxygen recognizes anything in the docstrings as verbatim\ndetailed description."],"is_intro":true}
+
+
+---===DONE===---