Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/check_urls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Check URLs

on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: urls-checker-code
uses: urlstechie/urlchecker-action@master
with:
subfolder: sphinx_runpython
file_types: .md,.py,.rst,.ipynb
print_all: false
timeout: 2
retry_count# : 2
# 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
exclude_patterns: https://dumps.wikimedia.org/
# force_pass : true

- name: urls-checker-docs
uses: urlstechie/urlchecker-action@master
with:
subfolder: _doc
file_types: .md,.py,.rst,.ipynb
print_all: false
timeout: 2
retry_count# : 2
# exclude_urls: https://github, ...
# exclude_patterns: https://github.com/...
# force_pass : true
25 changes: 23 additions & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Documentation

on: [push, pull_request]
on: [push]

jobs:
build_wheels:
Expand All @@ -26,6 +26,28 @@ jobs:
- name: Install requirements-dev.txt
run: python -m pip install -r requirements-dev.txt

- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements-dev.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-

- name: Generate coverage report
run: |
pip install pytest
pip install pytest-cov
export PYTHONPATH=.
pytest --cov=./_unittests/ --cov-report=xml --durations=10 --ignore-glob=**LONG*.py --ignore-glob=**notebook*.py
export PYTHONPATH=

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Install
run: python -m pip install -e .

Expand All @@ -34,7 +56,6 @@ jobs:
cp LICENSE* ./_doc
cp CHANGELOGS* ./_doc


- name: Documentation
run: python -m sphinx ./_doc ./dist/html -n -w doc.txt

Expand Down
13 changes: 13 additions & 0 deletions _unittests/ut__main/test_helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import unittest
from sphinx_runpython.ext_test_case import ExtTestCase
from sphinx_runpython.conf_helper import has_dvipng, has_dvisvgm


class TestHelpers(ExtTestCase):
def test_dvis(self):
self.assertIn(has_dvipng(), {True, False})
self.assertIn(has_dvisvgm(), {True, False})


if __name__ == "__main__":
unittest.main(verbosity=2)
25 changes: 25 additions & 0 deletions sphinx_runpython/conf_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from .runpython import run_cmd


def _check_cmd(cmd):
try:
stdout, _ = run_cmd(f"{cmd} --help", wait=True)
except FileNotFoundError:
return False
if cmd in stdout:
return True
return False


def has_dvipng():
"""
Checks `dvipng` is installed.
"""
return _check_cmd("dvipng")


def has_dvisvgm():
"""
Checks `dvisvgm` is installed.
"""
return _check_cmd("dvisvgm")
7 changes: 3 additions & 4 deletions sphinx_runpython/docassert/sphinx_docassert_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def check_typed_make_field(
):
"""
Overwrites function
#L197>`_.
`make_field <https://github.com/sphinx-doc/sphinx/blob/master/sphinx/util/docfields.py
`make_field
<https://github.com/sphinx-doc/sphinx/blob/master/sphinx/util/docfields.py#L197>`_.
Processes one argument of a function.

:param self: from original function
Expand Down Expand Up @@ -116,8 +116,7 @@ def override_transform(self, other_self, node):
"""
Transform a single field list *node*.
Overwrite function `transform
<https://github.com/sphinx-doc/sphinx/blob/
master/sphinx/util/docfields.py#L271>`_.
<https://github.com/sphinx-doc/sphinx/blob/master/sphinx/util/docfields.py#L271>`_.
It only adds extra verification and returns results from
the replaced function.

Expand Down
4 changes: 3 additions & 1 deletion sphinx_runpython/ext_io_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,9 @@ def download_requirejs(
local = download(filename, to)
except ReadUrlException as e: # pragma: no cover
# We implement a backup plan.
new_filename = "http://www.xavierdupre.fr/enseignement/setup/require.js/2.3.6/require.js"
new_filename = (
"https://requirejs.org/docs/release/2.3.6/minified/require.js"
)
try:
local = download(new_filename, to)
except ReadUrlException:
Expand Down
4 changes: 2 additions & 2 deletions sphinx_runpython/gdot/sphinx_gdot_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ def depart_gdot_node_html_svg(self, node):
def visit_gdot_node_html(self, node):
"""
visit collapse_node, the function switches between
`graphviz.py <https://github.com/sphinx-doc/sphinx/blob/
master/sphinx/ext/graphviz.py>`_ and the :epkg:`SVG` format.
`graphviz.py <https://github.com/sphinx-doc/sphinx/blob/master/sphinx/ext/graphviz.py>`_
and the :epkg:`SVG` format.
"""
if node["format"].lower() == "png":
from sphinx.ext.graphviz import html_visit_graphviz
Expand Down
10 changes: 0 additions & 10 deletions sphinx_runpython/github_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ def _linkcode_resolve(domain, info, package, url_fmt, revision):
Determine a link to online source for a class/method/function

This is called by sphinx.ext.linkcode

An example with a long-untouched module that everyone has:

>>> _linkcode_resolve('py', {'module': 'tty',
... 'fullname': 'setraw'},
... package='tty',
... url_fmt='http://hg.python.org/cpython/file/'
... '{revision}/Lib/{package}/{path}#L{lineno}',
... revision='xxxx')
'http://hg.python.org/cpython/file/xxxx/Lib/tty/tty.py#L18'
"""

if revision is None:
Expand Down
4 changes: 3 additions & 1 deletion sphinx_runpython/runpython/run_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def skip_run_cmd(
def run_cmd(
cmd,
sin="",
shell=sys.platform.startswith("win"),
shell=None,
wait=False,
log_error=True,
stop_running_if=None,
Expand Down Expand Up @@ -184,6 +184,8 @@ def run_cmd(
``__exit__`` should be called if wait if False.
Parameter *prefix_log* was added.
"""
if shell is None:
shell = sys.platform.startswith("win")
if prefix_log is None:
prefix_log = ""
if logf is not None:
Expand Down