Skip to content

Commit e8c7229

Browse files
committedMay 13, 2022
[#2] fix string and symlink handling, adding first basic tests
1 parent 4f1fd7d commit e8c7229

30 files changed

+1610
-37
lines changed
 

‎.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ instance/
6969
.scrapy
7070

7171
# Sphinx documentation
72-
docs/_build/
72+
_build/
7373

7474
# PyBuilder
7575
target/
@@ -131,4 +131,4 @@ dmypy.json
131131
.envrc
132132
.idea
133133

134-
_collections/
134+
_collections/

‎Makefile

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
SRC_FILES = sphinxcontrib/ tests/ noxfile.py
2+
3+
.PHONY: list
4+
list:
5+
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
6+
7+
.PHONY: lint
8+
lint:
9+
pre-commit run --all-files
10+
11+
.PHONY: test
12+
test:
13+
poetry run pytest -n auto --tb=long tests/
14+
15+
.PHONY: test
16+
test-short:
17+
poetry run pytest -n auto --tb=long --ignore-glob="*official*" tests/
18+
19+
.PHONY: test-matrix
20+
test-matrix:
21+
nox
22+
23+
.PHONY: docs-html
24+
docs-html:
25+
poetry run sphinx-build -a -E -j auto -b html docs/ docs/_build
26+
27+
.PHONY: docs-html
28+
docs-html-fast:
29+
poetry run sphinx-build -j auto -b html docs/ docs/_build
30+
31+
.PHONY: docs-pdf
32+
docs-pdf:
33+
poetry run make --directory docs/ clean && make --directory docs/ latexpdf
34+
35+
36+
.PHONY: docs-linkcheck
37+
docs-linkcheck:
38+
poetry run make --directory docs/ linkcheck
39+
40+
.PHONY: format
41+
format:
42+
poetry run black ${SRC_FILES}
43+
poetry run isort ${SRC_FILES}

‎doc-requirements.txt

-1
This file was deleted.

‎docs/drivers/copy_file.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ Copies a a single from ``source`` to ``project``. Both should should have a vali
66
.. code-block:: python
77
88
collections = {
9-
'my_files: {
9+
'my_files': {
1010
'driver': 'copy_file',
1111
'source': '../extra_files/my_file.txt',
1212
'target': 'my_data/new_data.txt'
13-
}
1413
}
15-
}
14+
}
1615
1716
Clean up behavior
1817
-----------------
19-
During clean up the target file gets deleted.
18+
During clean up the target file gets deleted.

‎docs/drivers/function.rst

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ Executes a function referenced by ``source`` and writes its return value into a
1111
return string
1212
1313
collections = {
14-
'my_files: {
14+
'my_files': {
1515
'driver': 'function',
1616
'source': my_own_data,
1717
'target': 'my_data/my_file.txt'
1818
'write_result': True
1919
}
20-
}
21-
}
20+
}
2221
2322
The specified function gets 1 argument during the call: A dictionary which contains the complete configuration of the
2423
collection.

‎docs/drivers/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Using own drivers instead of e.g. a pure function call has several advantages:
5353
'source': '../tests/dummy/',
5454
'active': True,
5555
},
56+
}
5657
5758
If you have created an awesome driver, please consider to provide it to ``Sphinx-Collections`` by creating
5859
a PR on our `github project <https://github.com/useblocks/sphinx-collections>`_ .

‎docs/drivers/report.rst

+4-5
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ collections have not been executed before this report gets generated.
99
.. code-block:: python
1010
1111
collections = {
12-
'my_collection_report: {
12+
'my_collection_report': {
1313
'driver': 'report',
1414
'target': 'reports/collections.rst'
15-
}
16-
}
17-
}
15+
}
16+
}
1817
1918
.. hint::
2019

@@ -37,4 +36,4 @@ The following template is used to build the report:
3736

3837
Clean up behavior
3938
-----------------
40-
During clean up the target folders, which contains the report, gets deleted.
39+
During clean up the target folders, which contains the report, gets deleted.

‎docs/drivers/string.rst

+7-8
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ Copies a string defined in ``source`` into a file specified by ``target``.
66
.. code-block:: python
77
88
collections = {
9-
'my_files: {
9+
'my_files': {
1010
'driver': 'string',
1111
'source': 'Awesome, this is nice',
1212
'target': 'my_data/my_file.txt'
13-
}
14-
}
15-
}
13+
}
14+
}
1615
1716
You can also use more complex strings by assigning them to a variable.
1817

@@ -33,13 +32,13 @@ You can also use more complex strings by assigning them to a variable.
3332
"""
3433
3534
collections = {
36-
'my_files: {
35+
'my_files': {
3736
'driver': 'string',
3837
'source': my_string,
3938
'target': 'my_data/my_file.txt'
40-
}
41-
}
42-
}
39+
}
40+
}
41+
4342
4443
Clean up behavior
4544
-----------------

‎docs/requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sphinx>=3.4
2+
sphinxcontrib-collections
3+
gitpython

‎noxfile.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import nox
2+
from nox_poetry import session
3+
4+
PYTHON_VERSIONS = ["3.6", "3.8", "3.9.7"]
5+
SPHINX_VERSIONS = ["3.2", "3.5.4", "4.1", "4.2"]
6+
TEST_DEPENDENCIES = [
7+
"pytest",
8+
"pytest-xdist",
9+
"responses",
10+
"pyparsing!=3.0.4",
11+
"requests-mock",
12+
]
13+
14+
15+
def is_supported(python: str, sphinx: str) -> bool:
16+
return not (python == "3.6" and sphinx not in ["3.2"])
17+
18+
19+
def run_tests(session, sphinx):
20+
session.install(".")
21+
session.install(*TEST_DEPENDENCIES)
22+
session.run("pip", "install", f"sphinx=={sphinx}", silent=True)
23+
session.run("pip", "install", "-r", "docs/requirements.txt", silent=True)
24+
session.run("echo", "TEST FINAL PACKAGE LIST")
25+
session.run("pip", "freeze")
26+
session.run("make", "test", external=True)
27+
28+
29+
@session(python=PYTHON_VERSIONS)
30+
@nox.parametrize("sphinx", SPHINX_VERSIONS)
31+
def tests(session, sphinx):
32+
if is_supported(session.python, sphinx):
33+
run_tests(session, sphinx)
34+
else:
35+
session.skip("unsupported combination")
36+
37+
38+
@session(python="3.9")
39+
def linkcheck(session):
40+
session.install(".")
41+
# LinkCheck cn handle rate limits since Sphinx 3.4, which is needed as
42+
# our doc has to many links to github.
43+
session.run("pip", "install", "sphinx==3.5.4", silent=True)
44+
45+
session.run("pip", "install", "-r", "docs/requirements.txt", silent=True)
46+
session.run("make", "docs-linkcheck", external=True)

0 commit comments

Comments
 (0)
Please sign in to comment.