Skip to content

Read a doxygen doc of a specific function #90

Closed

Description

@tdegeus

Problem description

Thanks for the module!!

Consider

namespace name {

/**
 * @brief My first function.
 * @param a This is a parameter.
 */
int foo(int a);

/**
 * This is a class
 */
class Bar
{
public:
    /**
     * @brief Some counter
     * @return integer
     */
    int count();
};

} // namespace name

What is the API to read the doxygen doc of name::foo, name::Bar, or name::Bar::count?

In trying to get the first I already got lost. This is up to where I have gotten:

data = parse_string(txt)
for i in data.namespace.namespaces["name"].functions:
    print(i.name)

whereby I get stuck as I don't know how to easily match the name.

Reproducible example code

-

Activity

  1. virtuald commented on Dec 17, 2023

    @virtuald
    Member

    The PQName has a format function which turns the name into a consistent string.

  2. virtuald commented on Dec 17, 2023

    @virtuald
    Member

    I will note that I definitely agree that using this for very simple things is still rather annoying. I'm definitely open to ideas for adding things to make it simpler to retrieve information. Or maybe someone needs to create a few examples to show how to do these things? Or add documentation.

  3. tdegeus commented on Dec 18, 2023

    @tdegeus
    Author

    I guess that if one knows the syntax, many things are workable. The structure of C++ can be 'hard' so that a perfect and extremely syntax is never easy. I will play around and consider submitting an example for review. For now I document this example:

    from cxxheaderparser.simple import parse_string
    
    docstrings = {}
    
    data = parse_string(txt)
    for namespace in data.namespace.namespaces:
        for i in data.namespace.namespaces[namespace].functions:
            if i.doxygen:
                docstrings[f"{namespace}::{i.name.format()}"] = i.doxygen
    
        for i in data.namespace.namespaces[namespace].classes:
            class_name = i.class_decl.typename.format().split("class ")[1]
            docstrings[f"{namespace}::{class_name}"] = i.class_decl.doxygen
            for j in i.methods:
                if j.doxygen:
                    docstrings[f"{namespace}::{class_name}::{j.name.format()}"] = j.doxygen
  4. virtuald commented on Dec 19, 2023

    @virtuald
    Member

    The class name thing is a bit weird. Probably should add a ClassDecl.get_name which returns the typename segments only without 'class' or 'typename' (so just this line:

    return tn + "::".join(seg.format() for seg in self.segments)
    )?

  5. locked and limited conversation to collaborators on Dec 19, 2023
  6. converted this issue into a discussion #91 on Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions