thibaultmarin / hpp2plantuml

Convert C++ header files to PlantUML
MIT License
223 stars 35 forks source link

Nested namespace with empty top namespace #13

Closed DavidRisch closed 3 years ago

DavidRisch commented 3 years ago

If a namespace which contains a class is contained inside of a namespace which contains no classes, an error is thrown.

Minimal example:

hpp2plantuml --version
echo '
namespace first_ns::second_ns{
    class A{};
}
' > Example.h
hpp2plantuml -i Example.h

Output:

hpp2plantuml 0.8.0
Traceback (most recent call last):
  File "/usr/local/bin/hpp2plantuml", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/hpp2plantuml/hpp2plantuml.py", line 1474, in main
    flag_dep=args.flag_dep)
  File "/usr/local/lib/python3.6/dist-packages/hpp2plantuml/hpp2plantuml.py", line 1434, in CreatePlantUMLFile
    diag_render = diag.render()
  File "/usr/local/lib/python3.6/dist-packages/hpp2plantuml/hpp2plantuml.py", line 1267, in render
    ns_obj_map[ns_parent].append(ns_obj_map[ns])
KeyError: 'first_ns'

If a class is added to the top namespace, no error is thrown and the correct result is produced:

namespace first_ns::second_ns{
    class A{};
}

namespace first_ns{
    class B{};
}
thibaultmarin commented 3 years ago

Thanks for the detailed report. v0.8.1 should hopefully fix this. Please let me know if it doesn't.

DavidRisch commented 3 years ago

Thanks! v0.8.1 works perfectly.