robotpy/cxxheaderparser

[UNEXPECTED BEHAVIOR]: Docstrings Ignoring //

Closed this issue · 2 comments

zalo commented

Problem description

Took me a while to track it down to this line:
https://github.com/robotpy/cxxheaderparser/blob/main/cxxheaderparser/lexer.py#L763

I happened to be examining a library documented with // comments and needed to edit this line.

Could there be an option for aggressive comment checking?

Operating System

Windows

Installed Python Packages

No response

Reproducible example code

# Parsing this file: https://github.com/deepmind/mujoco/blob/main/include/mujoco/mjmodel.h
import json
import dataclasses
from cxxheaderparser.simple import parse_string, ParserOptions

with open("include/mujoco/mjmodel.h") as f:
    content = f.read()
    parsed_data = parse_string(content)

    with open("parsed_json.json", mode='w') as j:
        print(json.dump(dataclasses.asdict(parsed_data), j, indent=2))

Well, // is just a normal comment, not a doxygen comment.

I think if one wanted to be able to support this type of thing, then probably the best approach is to refactor the existing doxygen extraction support out into a separate object, and then make it so a user could provide a different object that would recognize comments differently. I'd rather it be separable like that instead of a bunch of if statements, because it'll just be harder to maintain in the future -- but I am open to other ideas if you can think of a way to make it not terribly messy?

I don't really care much about this, but I'm happy to accept a PR for it if it were done that way.

zalo commented

Fair enough; I'll make a PR if I find a robust/general solution. 👍