NaturalDocs / NaturalDocs

Natural Docs source code documentation system
http://www.naturaldocs.org
192 stars 33 forks source link

Inheritance Graph not showing unless class name completely matches #81

Closed Neko-Box-Coder closed 9 months ago

Neko-Box-Coder commented 2 years ago

Hi :wave:, first of all, thanks for answering my previous question and continuing to share this project with us.

As the title suggests, the inheritance graph doesn't show unless the class name completely matches the one in the comment. As scopes don't nest in the comment, the commented name doesn't match the class name in code if that class is declared under a namespace. So for example (below), SomeClass inherits OtherClass under the same namespace (SomeNamespace), but the parser doesn't pick up the inheritance because of the name mismatch.

SomeClass.hpp

//namespace: SomeNamespace
namespace SomeNamespace
{
    //class: SomeNamespace::SomeClass
    class SomeClass : public OtherClass
    {};

OtherClass.hpp

//namespace: SomeNamespace
namespace SomeNamespace
{
    //class: SomeNamespace::OtherClass
    class OtherClass
    {};
}

And in order to fix this, I would need to add the namespace prefix to all the class names (SomeNamespace::SomeClass & SomeNamespace::OtherClass) SomeClass.hpp

...
class SomeNamespace::SomeClass : public SomeNamespace::OtherClass
...

This isn't ideal as it is already declared under that namespace and doesn't make sense to repeat the namespace in code just to make the documentation generate correctly. I can upload an example for testing if needed. If you need more clarification, feel free to ask.

Neko-Box-Coder commented 2 years ago

I would imagine if C# didn't have full parsing, this would be a problem for it as well. And this problem would happen not just only in C++, but also in Java or similar as well. Unless there's something I missing, if so please tell me. _ I have no idea how NaturalDocs works under the hood, but I think there's no easy fix to this. My best guess for fixing this would be either a.) allowing the user to specify the inheritance in the comment b.) allow scope nesting

NaturalDocs commented 2 years ago

Okay, try this version. It has a partial fix. https://www.naturaldocs.org/download/temp/Natural_Docs_temp5.zip

So it will work for this:

// Class: A.B.MyClass
class MyClass { }

This works with caveats:

// Class: A.B.MyClass
class MyClass : public MyParentClass { }

It will show MyParentClass as a parent no matter what. The only issue is that it won't check to see if it should go to A.B.MyParentClass instead of global MyParentClass. I should be able to fix that later though. If it gets it wrong the only thing that happens is the parent in the inheritance tree won't be a clickable link to the parent's page, and the parent's page won't show MyClass as a child.

All of this also works with :: as a separator instead of a dot.

Neko-Box-Coder commented 2 years ago

Yeah, I can confirm the tree now shows the parent/base class, and it is assuming the class is in global therefore not clickable as you said.

Thanks for the update :+1:

NaturalDocs commented 2 years ago

This version should work for both cases: https://www.naturaldocs.org/download/temp/Natural_Docs_temp6.zip

Neko-Box-Coder commented 2 years ago

Perfect :tada: :tada: :tada:

I have tested both cases where there's the same class but in different namespace and in global, and it is working flawlessly. :100:

This is amazing, thanks a lot.

Seems like this is solved now. Should I close the issue now or continue to keep the issue open until official release?

NaturalDocs commented 2 years ago

I'll close it when it appears in a full release.

NaturalDocs commented 2 years ago

This fix has been included in Natural Docs 2.3 Development Release 1.

NaturalDocs commented 9 months ago

Natural Docs 2.3 was released which includes this fix so I'm closing the issue.