Skip to content

Commit 48922a2

Browse files
authored
Adds function to check dvi (#12)
* Adds function to check dvi * ut * fix links
1 parent 1ee7a03 commit 48922a2

9 files changed

Lines changed: 106 additions & 20 deletions

File tree

.github/workflows/check_urls.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Check URLs
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v3
11+
12+
- name: urls-checker-code
13+
uses: urlstechie/urlchecker-action@master
14+
with:
15+
subfolder: sphinx_runpython
16+
file_types: .md,.py,.rst,.ipynb
17+
print_all: false
18+
timeout: 2
19+
retry_count# : 2
20+
# exclude_urls: https://dumps.wikimedia.org/other/pageviews/%Y/%Y-%m/pageviews-%Y%m%d-%H0000.gz,https://dumps.wikimedia.org/frwiki/latest/latest-all-titles-in-ns0.gz
21+
exclude_patterns: https://dumps.wikimedia.org/
22+
# force_pass : true
23+
24+
- name: urls-checker-docs
25+
uses: urlstechie/urlchecker-action@master
26+
with:
27+
subfolder: _doc
28+
file_types: .md,.py,.rst,.ipynb
29+
print_all: false
30+
timeout: 2
31+
retry_count# : 2
32+
# exclude_urls: https://github, ...
33+
# exclude_patterns: https://github.com/...
34+
# force_pass : true

.github/workflows/documentation.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Documentation
22

3-
on: [push, pull_request]
3+
on: [push]
44

55
jobs:
66
build_wheels:
@@ -26,6 +26,28 @@ jobs:
2626
- name: Install requirements-dev.txt
2727
run: python -m pip install -r requirements-dev.txt
2828

29+
- name: Cache pip
30+
uses: actions/cache@v2
31+
with:
32+
path: ~/.cache/pip
33+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements-dev.txt') }}
34+
restore-keys: |
35+
${{ runner.os }}-pip-
36+
${{ runner.os }}-
37+
38+
- name: Generate coverage report
39+
run: |
40+
pip install pytest
41+
pip install pytest-cov
42+
export PYTHONPATH=.
43+
pytest --cov=./_unittests/ --cov-report=xml --durations=10 --ignore-glob=**LONG*.py --ignore-glob=**notebook*.py
44+
export PYTHONPATH=
45+
46+
- name: Upload coverage reports to Codecov
47+
uses: codecov/codecov-action@v3
48+
env:
49+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
50+
2951
- name: Install
3052
run: python -m pip install -e .
3153

@@ -34,7 +56,6 @@ jobs:
3456
cp LICENSE* ./_doc
3557
cp CHANGELOGS* ./_doc
3658
37-
3859
- name: Documentation
3960
run: python -m sphinx ./_doc ./dist/html -n -w doc.txt
4061

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import unittest
2+
from sphinx_runpython.ext_test_case import ExtTestCase
3+
from sphinx_runpython.conf_helper import has_dvipng, has_dvisvgm
4+
5+
6+
class TestHelpers(ExtTestCase):
7+
def test_dvis(self):
8+
self.assertIn(has_dvipng(), {True, False})
9+
self.assertIn(has_dvisvgm(), {True, False})
10+
11+
12+
if __name__ == "__main__":
13+
unittest.main(verbosity=2)

sphinx_runpython/conf_helper.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from .runpython import run_cmd
2+
3+
4+
def _check_cmd(cmd):
5+
try:
6+
stdout, _ = run_cmd(f"{cmd} --help", wait=True)
7+
except FileNotFoundError:
8+
return False
9+
if cmd in stdout:
10+
return True
11+
return False
12+
13+
14+
def has_dvipng():
15+
"""
16+
Checks `dvipng` is installed.
17+
"""
18+
return _check_cmd("dvipng")
19+
20+
21+
def has_dvisvgm():
22+
"""
23+
Checks `dvisvgm` is installed.
24+
"""
25+
return _check_cmd("dvisvgm")

sphinx_runpython/docassert/sphinx_docassert_extension.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def check_typed_make_field(
1919
):
2020
"""
2121
Overwrites function
22-
#L197>`_.
23-
`make_field <https://github.com/sphinx-doc/sphinx/blob/master/sphinx/util/docfields.py
22+
`make_field
23+
<https://github.com/sphinx-doc/sphinx/blob/master/sphinx/util/docfields.py#L197>`_.
2424
Processes one argument of a function.
2525
2626
:param self: from original function
@@ -116,8 +116,7 @@ def override_transform(self, other_self, node):
116116
"""
117117
Transform a single field list *node*.
118118
Overwrite function `transform
119-
<https://github.com/sphinx-doc/sphinx/blob/
120-
master/sphinx/util/docfields.py#L271>`_.
119+
<https://github.com/sphinx-doc/sphinx/blob/master/sphinx/util/docfields.py#L271>`_.
121120
It only adds extra verification and returns results from
122121
the replaced function.
123122

sphinx_runpython/ext_io_helper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,9 @@ def download_requirejs(
496496
local = download(filename, to)
497497
except ReadUrlException as e: # pragma: no cover
498498
# We implement a backup plan.
499-
new_filename = "http://www.xavierdupre.fr/enseignement/setup/require.js/2.3.6/require.js"
499+
new_filename = (
500+
"https://requirejs.org/docs/release/2.3.6/minified/require.js"
501+
)
500502
try:
501503
local = download(new_filename, to)
502504
except ReadUrlException:

sphinx_runpython/gdot/sphinx_gdot_extension.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ def depart_gdot_node_html_svg(self, node):
282282
def visit_gdot_node_html(self, node):
283283
"""
284284
visit collapse_node, the function switches between
285-
`graphviz.py <https://github.com/sphinx-doc/sphinx/blob/
286-
master/sphinx/ext/graphviz.py>`_ and the :epkg:`SVG` format.
285+
`graphviz.py <https://github.com/sphinx-doc/sphinx/blob/master/sphinx/ext/graphviz.py>`_
286+
and the :epkg:`SVG` format.
287287
"""
288288
if node["format"].lower() == "png":
289289
from sphinx.ext.graphviz import html_visit_graphviz

sphinx_runpython/github_link.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ def _linkcode_resolve(domain, info, package, url_fmt, revision):
2323
Determine a link to online source for a class/method/function
2424
2525
This is called by sphinx.ext.linkcode
26-
27-
An example with a long-untouched module that everyone has:
28-
29-
>>> _linkcode_resolve('py', {'module': 'tty',
30-
... 'fullname': 'setraw'},
31-
... package='tty',
32-
... url_fmt='http://hg.python.org/cpython/file/'
33-
... '{revision}/Lib/{package}/{path}#L{lineno}',
34-
... revision='xxxx')
35-
'http://hg.python.org/cpython/file/xxxx/Lib/tty/tty.py#L18'
3626
"""
3727

3828
if revision is None:

sphinx_runpython/runpython/run_cmd.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def skip_run_cmd(
119119
def run_cmd(
120120
cmd,
121121
sin="",
122-
shell=sys.platform.startswith("win"),
122+
shell=None,
123123
wait=False,
124124
log_error=True,
125125
stop_running_if=None,
@@ -184,6 +184,8 @@ def run_cmd(
184184
``__exit__`` should be called if wait if False.
185185
Parameter *prefix_log* was added.
186186
"""
187+
if shell is None:
188+
shell = sys.platform.startswith("win")
187189
if prefix_log is None:
188190
prefix_log = ""
189191
if logf is not None:

0 commit comments

Comments
 (0)