Skip to content

Use definition lists rather than blockquotes #107

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

Merged
merged 5 commits into from
Nov 1, 2017
Merged

Conversation

jnothman
Copy link
Member

@jnothman jnothman commented Sep 5, 2017

This probably falls under the category of "if it ain't broke, don't fix it", but I note that we're strangely using blockquotes for parameter listings instead of definition lists. UPDATED: now this PR proposes to use definition lists by default, with a switch to use the legacy blockquotes.

From RST docs:

A definition is a block indented relative to the term, and may contain multiple paragraphs and other body elements. There may be no blank line between a term line and a definition block (this distinguishes definition lists from block quotes).

(emphasis mine)

As shown in the screenshots below, there are formatting differences in the default stylesheets:

  • definition lists have more semantic HTML markup
  • parameter names are bolded in definition lists; we currently mark them up explicitly in numpydoc
  • type specs fill the place of classifiers in the RST spec, and are formatted with bold and italics
    • the : has the class classifier-delimiter and what follows has the class classifier
  • the definition (i.e. parameter description) has smaller margins on all sides, meaning the parameter listing is much more compact, and the description has more visual affinity with the parameter it describes.

definition lists (with this patch):
definition lists (with this patch)

blockquotes (at master)
blockquotes (at master)

Does anyone know of disadvantages to definition lists, or why they have not been used here?

This patch should probably be extended to ensure that the first line of a parameter description is not blank, or it will revert to the blockquote styling.

This also highlights a problem with numpydoc's tests: vertical whitespace is significant in RST, particularly its presence/absence, but tests currently ignore blank lines, which is a Bad Idea.

@pv
Copy link
Member

pv commented Sep 6, 2017

Such change may mess up existing stylesheets that assume something about the generated html.

@jnothman
Copy link
Member Author

jnothman commented Sep 6, 2017

I'm aware, and so I'm inclined to raise this issue and close the PR. But what we do currently is pretty weird.

@jnothman
Copy link
Member Author

jnothman commented Sep 6, 2017

FWIW, the background to my concern here is about trying to style the definition list... only to discover that we're not using a definition list, hence the term has no distinguishing markup around it.

@pv
Copy link
Member

pv commented Sep 6, 2017

The code is soon 10 years old, so if I wrote it I don't remember the reason for this any more.
If a reason is not obvious, it may well be there's no reason, TIMTOWTDI...

@jnothman
Copy link
Member Author

jnothman commented Sep 6, 2017 via email

@stefanv
Copy link
Contributor

stefanv commented Sep 6, 2017

Or, fix it to be consistent, and wait for complaints to pop up?

@jnothman
Copy link
Member Author

jnothman commented Sep 6, 2017

Well, there's no problem of internal inconsistency... it's just a weird use of RST and HTML.

@jnothman
Copy link
Member Author

I'd like to have this fixed, because it produces much more pleasant HTML... But I'm a bit of an idealist. One could have a switch on it.

Also, something I need to check: remove any blank lines at the beginning of the description.

@jnothman
Copy link
Member Author

I've pushed a change which uses definition lists by default but allows users requiring the legacy styling to switch this on with a config option to be removed in release 0.10. WDYT?

I've also changed the tests to be sensitive to the presence or absence of blank lines, but to ignore multiple (and those at the beginning or end), when comparing rendered and expected reST. Presence and absence of single blank lines is (very) significant in reST!

@pv
Copy link
Member

pv commented Nov 1, 2017

TBH, I would just make the change, maybe break stuff, and wait for complaints.
But also adding a temporary option is fine with me.

rebase needed.

@jnothman
Copy link
Member Author

jnothman commented Nov 1, 2017 via email

@pv
Copy link
Member

pv commented Nov 1, 2017

No harm in having an option --- I didn't see before commenting that you had already implemented the option.

@pv pv merged commit c5178bd into numpy:master Nov 1, 2017
jnothman added a commit to jnothman/numpydoc that referenced this pull request Nov 13, 2017
This issue results from numpy#107: the explicit bold styling was removed because Sphinx definition lists bolded the term by default. However, without ** surrounding param name, a name like word_ was being treated as a link. I also attempted to replace the _ with \_ but found that the backslashes showed in the HTML. Thus I have reverted to wrapping param names in **.
jarrodmillman added a commit to jarrodmillman/numpydoc that referenced this pull request Aug 9, 2022
jarrodmillman added a commit to jarrodmillman/numpydoc that referenced this pull request Aug 9, 2022
larsoner pushed a commit that referenced this pull request Aug 15, 2022
* Remove numpydoc_use_blockquotes

See #107

* Update docstring
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.

3 participants