ModECI / modelspec

Functionality for specifying models & enabling automatic serialization - will be used by MDF & NeuroMLlite
https://modeci.github.io/modelspec/
Apache License 2.0
3 stars 9 forks source link

Multiline docstrings are not handled well - do not propagate to documentation #13

Closed pgleeson closed 2 years ago

pgleeson commented 2 years ago

e.g. this: https://github.com/ModECI/modelspec/blob/0cdcac0f2bd4f139846c6b5ab18518d945ee4cef/examples/document.py#L22-L26

is only the last line in generated docs:

https://github.com/ModECI/modelspec/blob/0cdcac0f2bd4f139846c6b5ab18518d945ee4cef/examples/document.specification.json#L26

Required for proper documentation of MDF...

pgleeson commented 2 years ago

Something for @parikshit14 to look into.

parikshit14 commented 2 years ago

Hi @pgleeson, Found what's causing the problem. while parsing

 A model of a section of the :class:`Document`. 
 Will contain one :class:`Paragraph` or more. 

parse.long_description which is present inside def _parse_definition(cls): skips the first non-empty line. So what we can do is, we can add a label to the docstring like:

 Description:
 A model of a section of the :class:`Document`. 
 Will contain one :class:`Paragraph` or more. 

and hence this results with:

 "definition": "A model of a section of the :class:`Document`.\nWill contain one :class:`Paragraph` or more."
davidt0x commented 2 years ago

Hey @parikshit14,

Can you check if it parses the first line into the short_description attribute without modifying the docstring? If so, then I would just concatenate the short and long description if they are both present. I would rather not change the docstring formatting if possible since it is a standard.

parikshit14 commented 2 years ago

@davidt0x, ya that makes more sense. Will create a pull request for it.

pgleeson commented 2 years ago

Fixed by #14