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

doc: Fix truncated summary line #3235

Merged
merged 1 commit into from
Aug 31, 2017

Conversation

niboshi
Copy link
Member

@niboshi niboshi commented Aug 24, 2017

Fixes #3234.

The problem is in autosummary's algorithm on parsing docstring: https://github.com/sphinx-doc/sphinx/blob/1.6.3/sphinx/ext/autosummary/__init__.py#L341
It treats the substring which ends with a period followed by a space (or a EOL) as the "first sentence", which trucate the string at e.g. "a.k.a. SOMETHING".

This PR interferes that algorithm by placing \ followed by an extra space before the existing space, which translates to an empty string. (I'm not sure if this is the correct use of the sequence. But at least it works)

Additionally I put a code to check if docstrings are compliant with autosummary's algorithm.

TODO: Port to CuPy

@niboshi niboshi added cat:bug Bug report or fix. cat:document Documentation such as function documentations, comments and tutorials. to-be-backported Pull request that should be backported. labels Aug 24, 2017

# Extract until the first blank line if any.
try:
doc = doc[:doc.index('')]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If doc does not have '', index() will raise ValueError (thus doc is not modified).
If it does, index() returns the index of '', so this statement extracts elements up until '', if any.

>>> a = ['a', 'b', 'c']                                                                                                                                                                                            
>>> a[:a.index('b')]                                                                                                                                                                                               
['a']

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I understand.

@okuta okuta added this to the v3.0.0rc1 milestone Aug 31, 2017
@okuta okuta self-assigned this Aug 31, 2017
@okuta
Copy link
Member

okuta commented Aug 31, 2017

LGTM!

@okuta okuta merged commit e0ce788 into chainer:master Aug 31, 2017
okuta added a commit to okuta/chainer that referenced this pull request Aug 31, 2017
@niboshi niboshi deleted the doc-fix-truncated-summary branch August 31, 2017 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:bug Bug report or fix. cat:document Documentation such as function documentations, comments and tutorials. to-be-backported Pull request that should be backported.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants