Repository navigation
Fixes docstrings and sets private members - #96
kushagra189 wants to merge 3 commits into
Conversation
uniqueg
left a comment
There was a problem hiding this comment.
I'm really sorry, but I think there's been quite some misunderstanding. Most of the changes you made are going in the wrong direction. The main point of the issue was to check the API docs on Read the Docs, find instances where the docstrings don't render well and try to fix those. In most cases this would probably mean to use the correct reStructuredText formatting, especially with a view to their use in Python docs (see here: https://www.python.org/dev/peps/pep-0287/#docstring-significant-features). A minor point was to check the consistency of the docstrings with the general recommendations (https://www.python.org/dev/peps/pep-0257/) and Google style (https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html), but in cases of ambiguity or multiple choices (see individual comments on class level vs class constructor docstrings, skipping explicit type annotations and defaults) keep the one that is most prevalent in our docs (because I did already think quite hard about which one to pick and might just not have caught every single instance for each when doing reviews).
I know this is annoying work, and in this particular case it will probably mean to go back and start a new PR entirely, so I understand if you'd rather not do it. Please let me know. And again, I'm really sorry for the misunderstanding, I should have caught earlier that this wasn't really going in the right direction (or perhaps the right direction, but way ahead).
|
|
||
| Returns: | ||
| A Connexion app instance. | ||
| app (App): A Connexion app instance. |
There was a problem hiding this comment.
I'm really sorry to nag again about this PR (and probably should have seen this before), but since we are doing type hints (and those translate nicely to the API docs currently), we should not explicitly annotate parameter and return types in the docstrings again. The reason (apart from additional work) is that this is almost certainly going to lead to diverging actual type annotations and those mentioned in the docstrings, because comments are frequently not updated when the code is. The actual code base (and Python type hints can be considered part of that) should be the authoritative truth whenever possible, to avoid just the problem of code and comments diverging. Using only type hints is therefore MUCH better in this case. You can compare the second example here to see that this is fully within the Google docstring scope.
| OSError: File cannot be read from or written to. | ||
| yaml.YAMLError: YAML cannot be (de)serialized. | ||
|
|
||
| Returns: |
There was a problem hiding this comment.
The Google style docstring examples or description here and here do not mention that sections like Raises and Returns should be arranged alphabetically. Rather, the order typically seems to be:
- Summary line (should fit on one line)
- Extended description
NotesArgs(followed byAttributes, if applicable)ReturnsRaisesExamples
| specs: List[SpecConfig], | ||
| ) -> App: | ||
| """ | ||
| Register OpenAPI specs with Connexion app. |
There was a problem hiding this comment.
Given that Connexion is also a package name, one could perhaps use connexion in single backticks as is described here for any Python identifiers (see third bullet point).
| yaml.YAMLError: YAML cannot be (de)serialized. | ||
|
|
||
| Returns: | ||
| App: A Connexion app instance. |
There was a problem hiding this comment.
Again: please no type annotations in docstrings
|
|
||
| Args: | ||
| config_file (Optional[str], optional): Path to config file in YAML | ||
| format. Defaults to None. |
There was a problem hiding this comment.
Defaults are also obvious from the function definitions and thus should be omitted. Diverging comments and code base are an even bigger problem here, as defaults are changed relatively frequently and users might end up assuming (and reporting) wrong usage parameters
| contains the database object; `config['database']['collections']` | ||
| contains a dictionary of collection objects. | ||
| MongoConfig: Flask application with updated config: | ||
| ``config['database']['database']`` contains the database object; |
|
|
||
| Optionally, basic authorization can be set by environment variables. | ||
| Note: | ||
| Optionally, basic authorization can be set by environment variables. |
There was a problem hiding this comment.
Perhaps not really part of this issue, but how? :)
| * `regular`: The exception is logged with the entire traceback | ||
| stack, usually on multiple lines. | ||
| exc (BaseException): The exception to log. | ||
| format (str, optional): One of 'oneline' (default), 'minimal', or |
There was a problem hiding this comment.
All literals probably should have double backticks surrounding them
| YAML file structure, see :py:class:`foca.models.config.Config()`. | ||
| config (Optional[str], optional): Path to a YAML application | ||
| configuration file. For required YAML file structure, see | ||
| :py:class:`foca.models.config.Config()`. Defaults to None. |
There was a problem hiding this comment.
Does the use of the : to define the Python identifier type (according to this document, fourth bullet point) lead to improved rendering? Specifically, does it create a link to that model? If not, I think we can omit it. Otherwise I think we should use wherever we are referring to a Python identifier
There was a problem hiding this comment.
It actually seems to do so with the type definition, but not sure it will also do it without. I'm wondering because the behavior is mixed: some (perhaps all?) references to FOCA modules/classes are linked on the API docs, but if, in a description of a parameter of a function or method, we are referring to another parameter in that same method, there is no link created. Ideally, of course, all such instances should be cross-linked, with the exception perhaps of members in external Python modules (guess that would be too much to ask from Read the Docs, although I think VS Code with the Python extension indeed does that)
| Raises: | ||
| connexion.exceptions.Unauthorized: Raised if JWT could not be | ||
| successfully validated. | ||
| Unauthorized: Raised if JWT could not be successfully validated. |
There was a problem hiding this comment.
Unauthorized is not a standard Python error, and I think it's important that we indicate what error is raised specifically.
|
Deleting this PR and the branch since the changes were not in line with the required flow. |
Description
Google type docstrings were improper and did not adhere to the required format. Fixed them as per the standards mentioned under the official guidelines. For reference check:
Fixes #70
Type of change
Please delete options that are not relevant.
Checklist: