Skip to content

Commit c424447

Browse files
authored
Merge pull request #54 from executablebooks/improve-repo
🔧 MAINTAIN: Improve repository format
2 parents d29a636 + a863b98 commit c424447

File tree

14 files changed

+155
-82
lines changed

14 files changed

+155
-82
lines changed

.flake8

Lines changed: 0 additions & 3 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ coverage.xml
2222
*.py,cover
2323
.pytest_cache/
2424
*_build
25+
.vscode

.pre-commit-config.yaml

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,45 @@ exclude: >
1010
1111
repos:
1212

13-
- repo: git://github.com/pre-commit/pre-commit-hooks
14-
rev: v2.2.3
13+
- repo: https://github.com/pre-commit/pre-commit-hooks
14+
rev: v3.3.0
1515
hooks:
16-
- id: check-yaml
17-
- id: end-of-file-fixer
18-
- id: trailing-whitespace
16+
- id: check-json
17+
- id: check-yaml
18+
- id: end-of-file-fixer
19+
- id: trailing-whitespace
1920

20-
- repo: https://gitlab.com/pycqa/flake8
21-
rev: 3.7.9
21+
- repo: https://github.com/mgedmin/check-manifest
22+
rev: "0.46"
2223
hooks:
23-
- id: flake8
24+
- id: check-manifest
25+
args: [--no-build-isolation]
26+
additional_dependencies: [setuptools>=46.4.0]
27+
28+
- repo: https://github.com/pycqa/isort
29+
rev: 5.8.0
30+
hooks:
31+
- id: isort
2432

2533
- repo: https://github.com/psf/black
2634
rev: 20.8b1
2735
hooks:
28-
- id: black
36+
- id: black
37+
38+
- repo: https://gitlab.com/pycqa/flake8
39+
rev: 3.8.4
40+
hooks:
41+
- id: flake8
42+
additional_dependencies: [flake8-bugbear==21.3.1]
43+
44+
- repo: https://github.com/pre-commit/mirrors-mypy
45+
rev: v0.790
46+
hooks:
47+
- id: mypy
48+
additional_dependencies: ["sphinx>=3,<4"]
49+
exclude: tests/roots/test-codeCellTransforms/conf.py
50+
51+
- repo: https://github.com/asottile/setup-cfg-fmt
52+
rev: v1.16.0
53+
hooks:
54+
- id: setup-cfg-fmt

MANIFEST.in

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
exclude .flake8
1+
exclude docs
2+
recursive-exclude docs *
3+
exclude tests
4+
recursive-exclude tests *
5+
26
exclude .pre-commit-config.yaml
7+
exclude .readthedocs.yml
38
exclude tox.ini
9+
exclude codecov.yml
410

511
include LICENSE
612
include MANIFEST.in
713
include README.md
14+
include CHANGELOG.md
815

16+
include jupyterbook_latex/py.typed
917
recursive-include jupyterbook_latex/theme *

jupyterbook_latex/__init__.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1+
import os
2+
from pathlib import Path
3+
4+
from docutils import nodes as docnodes
5+
from sphinx import builders
6+
from sphinx.util import logging
7+
from sphinx.util.fileutil import copy_asset_file
8+
19
from .nodes import (
2-
HiddenCellNode,
3-
visit_HiddenCellNode,
410
H2Node,
5-
visit_H2Node,
6-
depart_H2Node,
711
H3Node,
8-
visit_H3Node,
12+
HiddenCellNode,
13+
depart_H2Node,
914
depart_H3Node,
15+
visit_H2Node,
16+
visit_H3Node,
17+
visit_HiddenCellNode,
1018
)
1119
from .transforms import (
12-
codeCellTransforms,
1320
LatexMasterDocTransforms,
1421
ToctreeTransforms,
22+
codeCellTransforms,
1523
handleSubSections,
1624
)
17-
import os
18-
from sphinx import builders
19-
from sphinx.util import logging
20-
from sphinx.util.fileutil import copy_asset_file
21-
from pathlib import Path
22-
23-
from docutils import nodes as docnodes
2425

2526
__version__ = "0.2.0"
2627
"""jupyterbook-latex version"""

jupyterbook_latex/nodes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""AST nodes to designate notebook components."""
22
from docutils import nodes
3+
34
from .utils import sphinxEncode
45

56

jupyterbook_latex/py.typed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Marker file for PEP 561

jupyterbook_latex/transforms.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
from pathlib import Path
2+
from typing import Any
3+
14
import docutils
25
import yaml
3-
from typing import Any
4-
from pathlib import Path
56
from myst_nb import nodes
6-
from sphinx.transforms.post_transforms import SphinxPostTransform
7-
from sphinx.transforms import SphinxTransform
87
from sphinx import addnodes
98
from sphinx.builders.latex.nodes import thebibliography
9+
from sphinx.transforms import SphinxTransform
10+
from sphinx.transforms.post_transforms import SphinxPostTransform
1011

12+
from .nodes import H2Node, H3Node, HiddenCellNode
1113
from .utils import getFilenameWithSubpath, removeExtension
12-
from .nodes import HiddenCellNode, H2Node, H3Node
1314

1415
# Utility functions
1516

@@ -155,7 +156,7 @@ def checkNodeIsInPart(part, node):
155156

156157
docname = self.document["source"]
157158
if getFilenameWithSubpath(docname, 0) == self.app.config.master_doc:
158-
TOC_PATH = Path(self.app.confdir).joinpath("_toc.yml")
159+
TOC_PATH = Path(self.app.confdir or self.app.srcdir).joinpath("_toc.yml")
159160
tocfile = yaml.safe_load(TOC_PATH.read_text("utf8"))
160161

161162
# store bibliography nodes to append it at the end of doc

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[build-system]
2+
requires = ["setuptools>=46.4.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.isort]
6+
profile = "black"
7+
src_paths = ["jupyterbook_latex", "tests"]

setup.cfg

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
[metadata]
2+
name = jupyterbook_latex
3+
version = attr: jupyterbook_latex.__version__
4+
description = Latex specific features for jupyter book
5+
long_description = file: README.md
6+
long_description_content_type = text/markdown
7+
url = https://executablebooks.org/
8+
author = Executable Book Project
9+
author_email = [email protected]
10+
license = BSD-3-Clause
11+
license_file = LICENSE
12+
classifiers =
13+
License :: OSI Approved :: BSD License
14+
Programming Language :: Python :: 3
15+
Programming Language :: Python :: 3 :: Only
16+
Programming Language :: Python :: 3.6
17+
Programming Language :: Python :: 3.7
18+
Programming Language :: Python :: 3.8
19+
Programming Language :: Python :: 3.9
20+
Programming Language :: Python :: Implementation :: CPython
21+
22+
[options]
23+
packages = find:
24+
install_requires =
25+
myst_nb
26+
pyyaml
27+
sphinx>=3,<4
28+
python_requires = >=3.6
29+
include_package_data = True
30+
31+
[options.extras_require]
32+
code_style =
33+
pre-commit~=2.12
34+
rtd =
35+
myst-parser
36+
sphinx-book-theme
37+
testing =
38+
coverage
39+
coverage<5.0
40+
jupyter-book
41+
pytest>=3.6,<4
42+
pytest-cov~=2.8
43+
pytest-regressions
44+
sphinxcontrib-bibtex~=2.1.0
45+
texsoup
46+
47+
[options.packages.find]
48+
exclude =
49+
test*
50+
51+
[mypy]
52+
show_error_codes = True
53+
warn_unused_ignores = True
54+
warn_redundant_casts = True
55+
no_implicit_optional = True
56+
strict_equality = True
57+
58+
[flake8]
59+
max-line-length = 100
60+
extend-ignore = E203

setup.py

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,6 @@
1-
from setuptools import setup, find_packages
2-
from pathlib import Path
1+
# This file is needed for editable installs (`pip install -e .`).
2+
# Can be removed once the following is resolved
3+
# https://github.com/pypa/packaging-problems/issues/256
4+
from setuptools import setup
35

4-
lines = Path("jupyterbook_latex").joinpath("__init__.py")
5-
for line in lines.read_text().split("\n"):
6-
if line.startswith("__version__ ="):
7-
version = line.split(" = ")[-1].strip('"')
8-
break
9-
10-
setup(
11-
name="jupyterbook-latex",
12-
version=version,
13-
python_requires=">=3.6",
14-
author="Executable Book Project",
15-
author_email="[email protected]",
16-
url="https://executablebooks.org/",
17-
project_urls={
18-
"Source": "https://github.com/executablebooks/jupyter-book/",
19-
"Tracker": "https://github.com/executablebooks/jupyter-book/issues",
20-
},
21-
description="Latex specific features for jupyter book",
22-
packages=find_packages(),
23-
long_description=open("./README.md", "r").read(),
24-
long_description_content_type="text/markdown",
25-
license="BSD",
26-
install_requires=["sphinx>=3", "myst_nb", "pyyaml"],
27-
extras_require={
28-
"code_style": ["flake8<3.8.0,>=3.7.0", "black", "pre-commit==1.17.0"],
29-
"testing": [
30-
"coverage",
31-
"pytest>=3.6,<4",
32-
"pytest-cov~=2.8",
33-
"coverage<5.0",
34-
"pytest-regressions",
35-
"texsoup",
36-
"jupyter-book",
37-
"sphinxcontrib-bibtex~=2.1.0",
38-
],
39-
"rtd": [
40-
"sphinx>=3.0",
41-
"sphinx-book-theme",
42-
"myst-parser",
43-
],
44-
},
45-
include_package_data=True,
46-
)
6+
setup()

tests/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import shutil
2-
import pytest
3-
from sphinx.testing.path import path
42
from pathlib import Path
3+
4+
import pytest
55
from click.testing import CliRunner
6+
from sphinx.testing.path import path
67

78
pytest_plugins = "sphinx.testing.fixtures"
89

tests/test_toc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pickle
2+
23
import pytest
34
from jupyter_book import commands
45
from TexSoup import TexSoup

tox.ini

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,23 @@
77
envlist = py37-sphinx3
88

99
[testenv]
10-
# only recreate the environment when we use `tox -r`
11-
recreate = false
10+
usedevelop = true
1211

12+
[testenv:py{36,37,38,39}-sphinx{3,4}]
1313
extras = testing
1414
deps =
15-
sphinx>=3,<4
15+
sphinx3: sphinx>=3,<4
16+
sphinx4: sphinx>=4,<5
1617
commands =
1718
pytest {posargs}
1819

20+
[testenv:docs-{update,clean}]
21+
extras = rtd
22+
whitelist_externals = rm
23+
commands =
24+
clean: rm -rf docs/_build
25+
sphinx-build -nW --keep-going -b {posargs:html} docs/ docs/_build/{posargs:html}
26+
1927
[pytest]
2028
timeout = 100
2129
markers =

0 commit comments

Comments
 (0)