Skip to content

Deactivate smartquotes #11562

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 1 commit into from
Jul 10, 2018
Merged

Conversation

timhoffm
Copy link
Member

@timhoffm timhoffm commented Jul 3, 2018

PR Summary

Sphinx smartquotes converts simple quotes to typographic codes. Since we mainly use quotes to represent python strings in the docs without additional formatting (``'text'`` is really too cumbersome and visually distracting in plain docstrings), using straight quotes instead of typographic quotes is the better choice.

@tacaswell tacaswell added this to the v2.2-doc milestone Jul 4, 2018
@tacaswell
Copy link
Member

Would like feedback from @ImportanceOfBeingErnest before merge.

@matthew-brett
Copy link
Contributor

Seems reasonable to me - smartquotes are horrible.

@ImportanceOfBeingErnest
Copy link
Member

There is a slight chance I'm missing some implication of this proposed change, but as far as I can currently see, there is indeed no need for smart-quotes in the docs.

What I did find are just harmless cases like below (look at the word "styles"; top is without smart-quotes, bottom with smart-quotes):

image
image

In such cases, it doesn't really hurt to have them turned on - some people may find it more appealing actually.

Now it might help to turn smart-quotes off, because without smartquotes you may easily copy and paste text from the docs to the editor without the need to convert back to normal quotes - but I'm not sure if there are cases where that would apply in the matplotlib docs.

@timhoffm Is there any place in the docs where this change is particularly apparent or which motivated you to propose to turn them off, such that people can get a visual impression of the impact of this PR?

Possible implications to check:

  • Does this affect how the latex docs are produced/rendered in an undesireable way?
  • Are there cases where a double - (--) is used to create hyphens (–) which would then read as --? (This shouldnt be blocker, but one might then want to correct those.)

@jklymak
Copy link
Member

jklymak commented Jul 4, 2018

In LaTeX I'd normally do

``boo''

to get proper quotes. If that works for sphinx, then I'm 👍 on this change. If not, then neutral.

@timhoffm
Copy link
Member Author

timhoffm commented Jul 4, 2018

The motivation is stated in the original post:

Since we mainly use quotes to represent python strings in the docs without additional formatting (``'text'`` is really too cumbersome and visually distracting in plain docstrings), using straight quotes instead of typographic quotes is the better choice.

Some examples:

smart:
grafik

plain:
grafik

smart:
grafik

plain:
grafik

smart:
grafik

plain:
grafik

@ImportanceOfBeingErnest We indeed have a number of double-dashes (--). That would need fixing. Or better, is there a way to apply smartquotes to the dashes but not to the quotes. The docutils don't really say something about this. One could inject this by defining regular quotes in smartquotes_locales for English, but that's a bit hacky.

@jklymak
Copy link
Member

jklymak commented Jul 4, 2018

Very much agree that smartquotes have no business in anything that is rendered as code... thats terrible...

My tendancy is to merge this and fix any problems we find, but I won't merge right away in case others want a say....

@timhoffm timhoffm force-pushed the deactivate-smartquotes branch from 5332df7 to d0e7f5b Compare July 4, 2018 19:42
@timhoffm
Copy link
Member Author

timhoffm commented Jul 4, 2018

Indeed, one can keep the dashes and just deactivate the quotes. 🎉

@ImportanceOfBeingErnest
Copy link
Member

Now I see the point. Ideally, code should be code and hence embraced by double backticks (``).
However instead of doing this everywhere you would like to make this one change that fixes all of those cases.

Just mind that in that case you cannot keep the dashes (hyphens), because e.g. the linestyle "--" would still become a hyphen, as in

image

@timhoffm
Copy link
Member Author

timhoffm commented Jul 4, 2018

That's not nice. The idea was in the context of #10225 (section String Values), which is a pattern widely used in the docs.

For the above case of an accepts-list one could quite easily convert strings to literal strings while building the docs. However, I don't think it's easy to patch this into sphinx/numpydoc for rendering the original type infos.

Maybe we nevertheless have to go for the long cumbersome string literals ``'text'``? Alternatives would be deactivating smart quotes completely or escaping the --. The latter may however be confusing when looking at the plain text docs.

@jklymak
Copy link
Member

jklymak commented Jul 4, 2018

Do we really use -- that often for a hyphen? Personally I think just disable that as well; having a couple space "--" in the rendered docs is not as bad as having a long hyphen when we mean two dashes.

@timhoffm
Copy link
Member Author

timhoffm commented Jul 5, 2018

Yes, there are a lot of --: grep -R ' -- ' | wc yields 89 results.

@anntzer
Copy link
Contributor

anntzer commented Jul 5, 2018

Perhaps just add an escape (backslash) when we don't want the conversion? Yes, that makes the source a bit less legible at that point but it's a tradeoff to consider...

@timhoffm
Copy link
Member Author

timhoffm commented Jul 5, 2018

The escape would be really weird in the definitions of the line styles.

What I would prefer output-wise is a plain string in the plain docs but literal formatting in the html output. Can we intercept sphinx when processing parameter types and replace 'word' by ``'word'``?

@timhoffm timhoffm force-pushed the deactivate-smartquotes branch from d0e7f5b to aae1b6e Compare July 9, 2018 20:30
@timhoffm
Copy link
Member Author

timhoffm commented Jul 9, 2018

going back to the simple

smartquotes = False

For future reference. The alternative solution would be:

smartquotes = True
smartquotes_action = 'De'  # only replace 'D'ashes and 'e'llipses, not quotes

This is currently not chosen as it would convert the double dash in linestyle='--' into an em dash.

@jklymak
Copy link
Member

jklymak commented Jul 9, 2018

I think that makes sense... If someone wants to get worked up about -- in the main text, they can go through and fix....

@jklymak
Copy link
Member

jklymak commented Jul 10, 2018

Merging - the test failures were yesterday's kerfuffle...

@jklymak jklymak merged commit e8120cf into matplotlib:master Jul 10, 2018
lumberbot-app bot pushed a commit that referenced this pull request Jul 10, 2018
@timhoffm timhoffm deleted the deactivate-smartquotes branch July 10, 2018 19:12
jklymak added a commit that referenced this pull request Jul 10, 2018
…n-v2.2.2-doc

Backport PR #11562 on branch v2.2.2-doc
@timhoffm timhoffm mentioned this pull request Jan 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants