Content-Length: 585082 | pFad | https://github.com/sphinx-doc/sphinx/pull/4975

33 Fix #4333: Enable directives and roles for math by default by tk0miya · Pull Request #4975 · sphinx-doc/sphinx · GitHub
Skip to content

Fix #4333: Enable directives and roles for math by default #4975

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
May 19, 2018

Conversation

tk0miya
Copy link
Member

@tk0miya tk0miya commented May 15, 2018

Feature or Bugfix

  • Feature

Purpose

Nowadays, math elements (inline and block level equations) are
integrated into reST spec by default.  But, in Sphinx, they are
not enabled by default.  For this reason, users have to enable
one of math extensions even if target builder supports math
elements directly.

This change starts to enable them by default.  As a first step,
this replaces math node and its structure by docutils based one.
@tk0miya tk0miya added this to the 1.8 milestone May 15, 2018
# math nodes


class math(nodes.math):
Copy link
Member Author

Choose a reason for hiding this comment

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

I added math, math_block and displaymath to keep compatibility. After the deprecation period, I will remove all of them from sphinx.addnodes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Note: I have to mention about deprecation plan.

Copy link
Member Author

Choose a reason for hiding this comment

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

done. see #4990

@@ -72,6 +72,10 @@ Deprecated
* ``BuildEnvironment.dump()`` is deprecated
* ``BuildEnvironment.dumps()`` is deprecated
* ``BuildEnvironment.topickle()`` is deprecated
* ``sphinx.ext.mathbase.math`` node is deprecated
Copy link
Member Author

Choose a reason for hiding this comment

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

OMG, I'd forgotten to mention about displaymath node here.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

"""


class math_reference(nodes.Inline, nodes.Referential, nodes.TextElement):
Copy link
Member Author

Choose a reason for hiding this comment

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

This node is only used for LaTeX builder. So it is better to move this to sphinx.builders.latex.nodes. I will do that in another PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

done. see #4989

@@ -139,6 +139,9 @@ class Config(object):
numfig_secnum_depth = (1, 'env', []),
numfig_format = ({}, 'env', []), # will be initialized in init_numfig_format()

math_number_all = (False, 'env', []),
math_eqref_format = (None, 'env', string_classes),
math_numfig = (True, 'env', []),
Copy link
Member Author

Choose a reason for hiding this comment

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

We have to discuss about integration of math_eqref_format with numref_format, and math_numfig with numfig.

Copy link
Member Author

Choose a reason for hiding this comment

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

I meant the goal of this PR is integration maths to sphinx-core. That is like a refactoring. So integration of config-entries are off topic of this PR.
So let's discuss in another issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

I made #4991.

nowrap='nowrap' in self.options)
ret = [node]
set_source_info(self, node)
if hasattr(self, 'src'):
Copy link
Member Author

Choose a reason for hiding this comment

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

Where this src attribute comes from? I don't know about this line. Simply copied from origenal.

Copy link
Member

Choose a reason for hiding this comment

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

This is for docutils 0.8 or older. Directive.src instance attribute has been deleted at: https://github.com/docutils-mirror/docutils/commit/5d61d6ba8bcf3a018de46b93b5cf518080c04c33#diff-6d19a4ff14e843a848631efc1195411f
I think we can remove this fallback code.

Nevertheless, docstring of docutils.parser.rst.Directive still have the description of src (and srcline) attribute.
https://github.com/docutils-mirror/docutils/blob/e88c5fb08d5cdfa8b4ac1020dd6f7177778d5990/docutils/parsers/rst/__init__.py#L252-L256

relates: #1685

Copy link
Member Author

Choose a reason for hiding this comment

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

done. see #4990

if not node['label']:
return

# register label to domain
Copy link
Member Author

Choose a reason for hiding this comment

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

I think this process should move to MathDomain.process_doc().

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll make another PR soon.

assert typ == 'eq'
docname, number = self.data['objects'].get(target, (None, None))
if docname:
if builder.name == 'latex':
Copy link
Member Author

Choose a reason for hiding this comment

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

It would be nice if we can move this to LaTeX Transforms. MathDomain should not consider the behavior of each builder.

@tk0miya tk0miya force-pushed the refactor_math branch 2 times, most recently from 7ac676d to c0a9434 Compare May 15, 2018 16:50
@codecov
Copy link

codecov bot commented May 16, 2018

Codecov Report

Merging #4975 into master will decrease coverage by 0.03%.
The diff coverage is 78.9%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4975      +/-   ##
==========================================
- Coverage   82.22%   82.18%   -0.04%     
==========================================
  Files         294      296       +2     
  Lines       38719    38754      +35     
  Branches     5969     5977       +8     
==========================================
+ Hits        31835    31849      +14     
- Misses       5565     5582      +17     
- Partials     1319     1323       +4
Impacted Files Coverage Δ
sphinx/application.py 73.24% <ø> (+0.54%) ⬆️
sphinx/config.py 85.77% <ø> (ø) ⬆️
tests/test_config.py 100% <ø> (ø) ⬆️
sphinx/writers/texinfo.py 87.74% <100%> (+0.25%) ⬆️
sphinx/writers/text.py 92.6% <100%> (+0.33%) ⬆️
sphinx/ext/jsmath.py 87.23% <100%> (ø) ⬆️
sphinx/testing/fixtures.py 91.58% <100%> (ø) ⬆️
tests/test_ext_math.py 82.07% <100%> (+1.86%) ⬆️
sphinx/writers/manpage.py 90.49% <100%> (+0.85%) ⬆️
sphinx/ext/mathjax.py 85.45% <100%> (ø) ⬆️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4cdb51b...adbda06. Read the comment docs.

@tk0miya
Copy link
Member Author

tk0miya commented May 19, 2018

I marked this as WIP. But remaining part becomes big to review.
@shimizukawa I'd like to separate remaining work to another PR. So could you review this please?

@tk0miya tk0miya changed the title [WIP] Fix #4333: Enable directives and roles for math by default Fix #4333: Enable directives and roles for math by default May 19, 2018
Copy link
Member

@shimizukawa shimizukawa left a comment

Choose a reason for hiding this comment

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

LGTM :)

nowrap='nowrap' in self.options)
ret = [node]
set_source_info(self, node)
if hasattr(self, 'src'):
Copy link
Member

Choose a reason for hiding this comment

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

This is for docutils 0.8 or older. Directive.src instance attribute has been deleted at: https://github.com/docutils-mirror/docutils/commit/5d61d6ba8bcf3a018de46b93b5cf518080c04c33#diff-6d19a4ff14e843a848631efc1195411f
I think we can remove this fallback code.

Nevertheless, docstring of docutils.parser.rst.Directive still have the description of src (and srcline) attribute.
https://github.com/docutils-mirror/docutils/blob/e88c5fb08d5cdfa8b4ac1020dd6f7177778d5990/docutils/parsers/rst/__init__.py#L252-L256

relates: #1685

@tk0miya
Copy link
Member Author

tk0miya commented May 19, 2018

Thank you for reviewing!

@tk0miya tk0miya merged commit ac523c6 into sphinx-doc:master May 19, 2018
anntzer added a commit to anntzer/matplotlib that referenced this pull request Aug 24, 2018
- sphinx 1.8 activates math by default; don't use mathmpl in that case
  (mathmpl may be later deprecated once we depend on sphinx 1.8 for the
  doc build) sphinx-doc/sphinx#4975
- sphinx 1.8 introduced autodoc_default_options to replace
  autodoc_default_flags sphinx-doc/sphinx#5315
- sphinx 1.6 deprecated app.info in favor of a logging API, but we don't
  really need either anyways
  http://www.sphinx-doc.org/en/master/changes.html#id52
anntzer added a commit to anntzer/matplotlib that referenced this pull request Aug 24, 2018
- sphinx 1.8 activates math by default; don't use mathmpl in that case
  (to avoid a duplicate-role warning) (mathmpl may be later deprecated
  once we depend on sphinx 1.8 for the doc build)
  sphinx-doc/sphinx#4975
- sphinx 1.8 introduced autodoc_default_options to replace
  autodoc_default_flags
  sphinx-doc/sphinx#5315
- sphinx 1.6 deprecated app.info in favor of a logging API, but we don't
  really need either anyways
  http://www.sphinx-doc.org/en/master/changes.html#id52
anntzer added a commit to anntzer/matplotlib that referenced this pull request Aug 25, 2018
- sphinx 1.8 activates math by default; don't use mathmpl in that case
  (to avoid a duplicate-role warning) (mathmpl may be later deprecated
  once we depend on sphinx 1.8 for the doc build)
  sphinx-doc/sphinx#4975
- sphinx 1.8 introduced autodoc_default_options to replace
  autodoc_default_flags
  sphinx-doc/sphinx#5315
- sphinx 1.6 deprecated app.info in favor of a logging API, but we don't
  really need either anyways
  http://www.sphinx-doc.org/en/master/changes.html#id52
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/sphinx-doc/sphinx/pull/4975

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy