-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Pre-implement to render psuedxml from STDIN by module execute
- Loading branch information
Showing
3 changed files
with
62 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ jobs: | |
run: | | ||
source .venv/bin/activate | ||
pytest | ||
pytest functests | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
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 @@ | ||
"""Test cases for CLI testing.""" | ||
import subprocess | ||
|
||
|
||
def test_with_npm(): | ||
"""CLI I/O test with ``npm`` role.""" | ||
source = ":npm:`react`" | ||
expected = ( | ||
"\n".join( | ||
[ | ||
'<document source="<stdin>">', | ||
" <paragraph>", | ||
' <reference refuri="https://www.npmjs.com/package/react">', | ||
" react", | ||
] | ||
) | ||
+ "\n" | ||
) | ||
proc = subprocess.run( | ||
["python", "-m", "rst_multi_refs"], | ||
input=source.encode(), | ||
stdout=subprocess.PIPE, | ||
) | ||
assert proc.returncode == 0 | ||
assert proc.stdout == expected.encode() |
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,36 @@ | ||
"""CLI entrypoint for simple testing by users. | ||
.. note:: Current implementatoin is stub to pass functests. | ||
""" | ||
from typing import List, Optional | ||
|
||
from docutils import nodes | ||
from docutils.core import publish_cmdline | ||
from docutils.parsers.rst import roles | ||
from docutils.parsers.rst.states import Inliner | ||
|
||
|
||
def npm_reference_role( | ||
role: str, | ||
rawtext: str, | ||
text: str, | ||
lineno: int, | ||
inliner: Inliner, | ||
options: Optional[dict] = None, | ||
content: Optional[List[str]] = None, | ||
): | ||
"""Parse ``npm`` role.""" | ||
options = roles.normalized_role_options(options) | ||
messages = [] | ||
url = f"https://www.npmjs.com/package/{text}" | ||
return [nodes.reference(rawtext, text, refuri=url, **options)], messages | ||
|
||
|
||
def configure(): | ||
"""Set up using roles.""" | ||
roles.register_canonical_role("npm", npm_reference_role) | ||
pass | ||
|
||
|
||
configure() | ||
publish_cmdline() |