-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop parsing from overwriting Sphinx configuration (#422)
- Loading branch information
1 parent
0bec1bc
commit d2955c6
Showing
6 changed files
with
81 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""Utilities for side-effect-free rST parsing.""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from docutils.utils import new_document | ||
from sphinx.parsers import RSTParser | ||
from sphinx.util.docutils import sphinx_domains | ||
|
||
if TYPE_CHECKING: | ||
import optparse | ||
|
||
from docutils import nodes | ||
from docutils.frontend import Values | ||
|
||
|
||
def parse(inputstr: str, settings: Values | optparse.Values) -> nodes.document: | ||
"""Parse inputstr and return a docutils document.""" | ||
doc = new_document("", settings=settings) | ||
with sphinx_domains(settings.env): | ||
parser = RSTParser() | ||
parser.set_application(settings.env.app) | ||
parser.parse(inputstr, doc) | ||
return doc |
10 changes: 10 additions & 0 deletions
10
tests/roots/test-dummy/dummy_module_simple_default_role.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from __future__ import annotations | ||
|
||
|
||
def function(x: bool, y: int) -> str: # noqa: ARG001 | ||
""" | ||
Function docstring. | ||
:param x: `foo` | ||
:param y: ``bar`` | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Simple Module | ||
============= | ||
|
||
.. autofunction:: dummy_module_simple_default_role.function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters