Skip to content
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

Improvements to the location of the return type #300

Merged
merged 6 commits into from Jan 18, 2023

Conversation

hoodmane
Copy link
Collaborator

@hoodmane hoodmane commented Jan 18, 2023

The current strategy to place the rtype is still not fully satisfactory on my own documentation. I think this improves it to avoid any need for fudging.

  1. If there is an existing :rtype: don't add another
  2. If there is a :returns: anywhere, either add directly before it or modify the :returns: line as appropriate
  3. If there is a block of :param: documentation, add directly after this
  4. If there is a .. directive, add before the directive
  5. Add at the end

Step 4 could be refined further, we would really only like to break at directives that introduce headings.

Since it is very hard to decide where the :param: block ends based on directly analyzing the text so I parse the docstring into a docutils tree. From the tree it is not too hard to work out what we need to know.

The current strategy to place the rtype is still not fully satisfactory
on my own documentation. I think this improves it to avoid any need for
fudging.

1. If there is an existing :rtype: don't add another
2. If there is a :returns: anywhere, either add directly before it
   or modify the :returns: line as appropriate
3. If there is a block of :param: documentation, add directly after
   this
4. If there is a .. directive, add before the directive
5. Add at the end

Step 4 could be refined further, we would really only like to break at
directives that introduce headings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants