-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Layout a docstring parser base #28
Conversation
6271293
to
4692bad
Compare
If I look at |
The Google parser does use these attributes: I'd like to get rid of this "state" but I don't see how 😕 |
Then the |
I do that at the beginning of Maybe I should simply remove def parse(docstring, path, signature, return_type):
self.set_state(path, signature, return_type)
# do stuff, use self.state.signature and self.state.return_type as needed
# handle error, self.record_error will prefix with self.state.path
self.record_error("message")
# at the end
return sections, self.pop_state()
This what |
Another solution would be use no state at all, and pass all the arguments through every method. |
If you have to do that, move those state variables to |
I thought it would be convenient to give access to the object path, signature and return type to any parser implementation 😅 I'll see what I can do. Don't hesitate to open a PR based on this branch if you want to give it a try as well 🙂 In any case, thank you for your help! |
4692bad
to
8f82958
Compare
8f82958
to
1ce9802
Compare
Sorry but I don't see how I'm supposed to get rid of the state in the base parser class. The google parser needs the object path, signature and type, so these values must be passed from Besides, I think every parser will benefit from having access to the object signature and type, and the object path is required anyway for consistent error reporting. I will keep the base parser structure like that. I think it makes it easy to write a parser implementation. |
Yeah, Let's keep it as is right now. I can make an issue or PR to demonstrate what I mean. |
Alright, thanks 🙂 |
Related to #25
The idea is to lay things out for allowing contributors to implement different docstrings parsers more easily.