How to avoid namespace conflicts when project contains multiple languages that use the same namespace name?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to avoid namespace conflicts when project contains multiple languages that use the same namespace name?

andrewdpooch
This post has NOT been accepted by the mailing list yet.
Problem:
I have a project that contains libraries of both Tcl and Python.  By convention here, the top level namespace for any library function must be the name of the project, thus avoiding any ambiguity as to where the module is coming from (all project names are unique).  With project name being "foo", I need to expose a package in PYTHONPATH called "foo", and also a Tcl module called "foo".  If my project was either all Python or all Tcl, there would be a problem, but since there are two languages and Doxygen reads all the sources in based on a sing Doxyfile, what I end up with is a conflicting namespace and obvious way to differentiate Python modules from Tcl modules in the "Namespace list".

With a code base that looks like this:

  bin/
    ex_py_app.py
    ex_tcl_app.tcl

  lib/python/altera_foo
    __init__.py
    altera_foo.py  # import altera_foo/altera_foo

  lib/tcl/
    altera_foo.tcl  # package require altera_foo
    bar.tcl            # package require altera_foo::bar


I get this in the "Namespace list":
 
  (N) altera_foo         Tcl: example Tcl module
      (N) altera_foo     Python: example Python module
      (N) bar              Tcl: example nested Tcl module
  (N) ex_py_app        Python: example Python application
  (N) ex_tcl_app        Tcl: example Tcl application

You should see that there is a Python module reported underneath a Tcl namespace based on my briefs; had there been a nested Tcl namespace altera_foo::altera_foo (legal), it would clobber Python module altera_foo.altera_foo (legal).  The primary issue is readability; why in the world would anyone want to see an API description that consists of interleaved languages?  

What I'd like to see is this:

Tcl:
  (N) altera_foo         Tcl: example Tcl module
      (N) bar              Tcl: example nested Tcl module
  (N) ex_tcl_app        Tcl: example Tcl application

Python:
  (N) altera_foo         Python: example Python package
      (N) altera_foo     Python: example Python module
  (N) ex_py_app        Python: example Python application


I could not get the Namespace list to be interleaved.  

In an attempt to add python/ in the Namespace list hierarchy, I tried adding an __init__.py in the python directory and hacking the @package lines to be:
@package python.altera_foo.altera_foo
This got the hierarchy level in the Namespace list, but the API documentation would add the "python." prefix to all the class and function descriptions which would not be a correct specification.  Ex.
def python.altera_foo.altera_foo.my_function

I tried to hack the Tcl side as well with no success; Doxygen strictly builds the hierarchy by what exists in the code.

I also looked at 'groups', but this only created a tab called "modules"; it did not fix the interleaving and would not prevent clobbering.

Question:
Is there I can get Doxygen to not interleave the namespaces and clobber files in this case and get the output I want without hacking the Makefile to call doxygen multiple times with language specific Doxyfiles and and index.dox that binds the outputs together?

Thanks!