From 71f2f919fe7d396d22f407ad550d0156ec72efcb Mon Sep 17 00:00:00 2001 From: Steve Phelps Date: Tue, 19 Nov 2019 20:28:03 +0000 Subject: [PATCH 01/23] Allow configuration of initial section numbering via notebook metadata (#113) fixes #112, to specify initial section numbering *via* notebook metadata ``toc.base_numbering`` as set by the toc2 notebook plugin. --- docs/source/metadata_tags.rst | 19 +++++++++++++++++++ .../preprocessors/slides_from_markdown.py | 14 +++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/docs/source/metadata_tags.rst b/docs/source/metadata_tags.rst index bf75004..f7c9815 100644 --- a/docs/source/metadata_tags.rst +++ b/docs/source/metadata_tags.rst @@ -499,6 +499,25 @@ For **slide output**: - the value of slide can be true, “new” (to indicate the start of a new slide) or “notes” +Specifying the start section number in slide-shows +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +For **slide output**: + +.. code:: json + + { + "toc": { + "base_numbering": "3", + } + } + +- the above will set the first section number to 3 rather than 1 + +- note that the top-level key is "toc", and *not* "ipub"; this allows + the starting section number to be configured using the + `toc2 notebook extension `__ + Captions in a Markdown cell ~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/ipypublish/preprocessors/slides_from_markdown.py b/ipypublish/preprocessors/slides_from_markdown.py index c20c436..0d58ea0 100644 --- a/ipypublish/preprocessors/slides_from_markdown.py +++ b/ipypublish/preprocessors/slides_from_markdown.py @@ -174,8 +174,20 @@ def preprocess(self, nb, resources): latexdoc_tags = ["code", "error", "table", "equation", "figure", "text"] # break up titles cells_in_slide = 0 - header_levels = [] final_cells = FinalCells(self.header_slide) + + header_levels = [] + try: + base_numbering = nb.metadata.toc.base_numbering + header_levels = list(map(lambda x: int(x), base_numbering.split("."))) + header_levels[0] -= 1 + logging.debug("base_numbering = " + base_numbering) + logging.debug("header_levels = " + str(header_levels)) + except ValueError: + logging.warning("Invalid toc.base_numbering in notebook metadata") + except AttributeError: + logging.debug("No toc.base_numbering in notebook metadata; starting at 1") + for i, cell in enumerate(nb.cells): # Make sure every cell has an ipub meta tag From 5bd75314ae2c7d2fd23c4f13362913509c2f2164 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Thu, 19 Dec 2019 03:09:46 +0000 Subject: [PATCH 02/23] Pin nbsphinx test version (#127) --- .../basic_nb/expected/sphinx_nbsphinx.rst | 15 +-------------- setup.py | 2 +- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/ipypublish/tests/test_files/basic_nb/expected/sphinx_nbsphinx.rst b/ipypublish/tests/test_files/basic_nb/expected/sphinx_nbsphinx.rst index c71a1d6..458b68e 100644 --- a/ipypublish/tests/test_files/basic_nb/expected/sphinx_nbsphinx.rst +++ b/ipypublish/tests/test_files/basic_nb/expected/sphinx_nbsphinx.rst @@ -11,7 +11,7 @@ some text a=1 print(a) -.. nboutput:: ansi +.. nboutput:: .. rst-class:: highlight @@ -23,19 +23,6 @@ some text .. raw:: latex - % - { - \kern-\sphinxverbatimsmallskipamount\kern-\baselineskip - \kern+\FrameHeightAdjust\kern-\fboxrule - \vspace{\nbsphinxcodecellspacing} - \sphinxsetup{VerbatimBorderColor={named}{nbsphinx-code-border}} - \sphinxsetup{VerbatimColor={named}{white}} - \fvset{hllines={, ,}}% \begin{sphinxVerbatim}[commandchars=\\\{\}] 1 \end{sphinxVerbatim} - } - % The following \relax is needed to avoid problems with adjacent ANSI - % cells and some other stuff (e.g. bullet lists) following ANSI cells. - % See https://github.com/sphinx-doc/sphinx/issues/3594 - \relax diff --git a/setup.py b/setup.py index 339889d..6adcc2f 100755 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ "pytest-cov", "coverage", "pillow", - "nbsphinx", + "nbsphinx>=0.5,<0.6", "ipykernel", "sphinx>=1.6", "sphinxcontrib-bibtex", From 9bc65640480830c94d88619f4f7b634ac1f03f50 Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Thu, 19 Dec 2019 05:09:33 +0100 Subject: [PATCH 03/23] DOCs fix typo nbshinx -> nbsphinx (#126) --- docs/source/acknowledgements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/acknowledgements.md b/docs/source/acknowledgements.md index 13d806b..fe6631c 100644 --- a/docs/source/acknowledgements.md +++ b/docs/source/acknowledgements.md @@ -7,6 +7,6 @@ I also took strong influence from: - [Julius Schulz](http://blog.juliusschulz.de/blog/ultimate-ipython-notebook) - [Dan Mackinlay](https://livingthing.danmackinlay.name/jupyter.html) - Notebook concatenation was adapted from [nbconvert issue#253](https://github.com/jupyter/nbconvert/issues/253) -- [nbshinx](https://nbsphinx.readthedocs.io) +- [nbsphinx](https://nbsphinx.readthedocs.io) - [panflute](http://scorreia.com/software/panflute/) - [pandoc-xnos](https://github.com/tomduck/pandoc-xnos) From 0f32615de8829936fdf1a5e223d01572d8d82bb3 Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Thu, 19 Dec 2019 05:22:22 +0100 Subject: [PATCH 04/23] DOCs fix typo nbshinx -> nbsphinx (#125) --- docs/source/sphinx_ext_notebook.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/sphinx_ext_notebook.rst b/docs/source/sphinx_ext_notebook.rst index 039c4fd..92edf5a 100644 --- a/docs/source/sphinx_ext_notebook.rst +++ b/docs/source/sphinx_ext_notebook.rst @@ -4,7 +4,7 @@ ipypublish.sphinx.notebook ========================== :py:mod:`ipypublish.sphinx.notebook` is adapted from -`nbshinx `_, to provide a +`nbsphinx `_, to provide a `sphinx extension `_ for converting notebooks with :py:class:`ipypublish.convert.main.IpyPubMain`. From 43c6ff4be0b8eac3c7d2062cec6d1e459d5baa0c Mon Sep 17 00:00:00 2001 From: Steve Phelps Date: Thu, 19 Dec 2019 04:50:42 +0000 Subject: [PATCH 05/23] Allow additional custom stylesheet to be linked in slide output (#122) Allow custom stylesheet to be added to slideshow via `ipub.customcss` notebook metadata, and added documentation for `ipub.customcss`. fixes #121 --- doc8.ini | 3 ++ docs/source/metadata_tags.rst | 28 +++++++++++++++---- ipypublish/schema/doc_metadata.schema.json | 3 ++ .../segments/std-slides.html-tplx.json | 6 ++++ 4 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 doc8.ini diff --git a/doc8.ini b/doc8.ini new file mode 100644 index 0000000..f6cc455 --- /dev/null +++ b/doc8.ini @@ -0,0 +1,3 @@ +[doc8] + +ignore-path-errors=docs/source/metadata_tags.rst;D001 diff --git a/docs/source/metadata_tags.rst b/docs/source/metadata_tags.rst index f7c9815..86da028 100644 --- a/docs/source/metadata_tags.rst +++ b/docs/source/metadata_tags.rst @@ -198,6 +198,22 @@ for placement options. .. _pandoc_doc_metadata: + +Adding a stylesheet to slides +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +For **slide output**, the following notebook-level metadata: + +.. code:: json + + { + "ipub": { + "customcss": "mystylesheet.css" + } + } + +will link the additional stylesheet `mystylesheet` in the resulting html. This can be used, for example, to display a log on each slide. + Pandoc Markdown Conversion ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -383,7 +399,7 @@ all extra tags are optional: Output Figures ~~~~~~~~~~~~~~ -For **figures** (i.e. any graphics output by the code), enter in cell +For **figures** (i.e. any graphics output by the code), enter in cell metadata: .. code:: json @@ -422,7 +438,7 @@ metadata: Output Tables ~~~~~~~~~~~~~ -For **tables** (e.g. those output by ``pandas``), enter in cell +For **tables** (e.g. those output by ``pandas``), enter in cell metadata: .. code:: json @@ -459,7 +475,7 @@ metadata: Output Equations ~~~~~~~~~~~~~~~~ -For **equations** (e.g. those output by ``sympy``), enter in cell +For **equations** (e.g. those output by ``sympy``), enter in cell metadata: .. code:: json @@ -540,7 +556,7 @@ Then, during the the postprocessor stage, this cell will be removed from the notebook object, and its text stored as a *resource*; - the cell’s text is the first paragraph of the markdown string, - i.e. nothing after a newline (:code:`\n`) + i.e. nothing after a newline (:code:`\n`) - if there are multiple instance of the same cation name, then only the last instance will be stored @@ -605,10 +621,10 @@ latex/pdf, you get the static image or b) if you export to html/reveal slides, you get the html. - use either filepath or url -- other_files are files required by the html file (e.g. javascript +- other_files are files required by the html file (e.g. javascript libraries). These files will be copied to the the same folder as the html -- width/height refers to the fraction of the viewspace used (e.g. 0.5 +- width/height refers to the fraction of the viewspace used (e.g. 0.5 width -> 50vw and 0.5 height -> 50vh) An example of how this works is in the diff --git a/ipypublish/schema/doc_metadata.schema.json b/ipypublish/schema/doc_metadata.schema.json index 8316370..178e9d2 100644 --- a/ipypublish/schema/doc_metadata.schema.json +++ b/ipypublish/schema/doc_metadata.schema.json @@ -12,6 +12,9 @@ "type": "string", "default": "english" }, + "customcss": { + "description": "additional custom stylesheet to link" + }, "titlepage": { "description": "options for creating the title page", "type": [ diff --git a/ipypublish/templates/segments/std-slides.html-tplx.json b/ipypublish/templates/segments/std-slides.html-tplx.json index 1c5a9ca..7126ca2 100644 --- a/ipypublish/templates/segments/std-slides.html-tplx.json +++ b/ipypublish/templates/segments/std-slides.html-tplx.json @@ -39,6 +39,12 @@ "", "", "", + "{%- if nb.metadata.ipub -%}", + "{%- if nb.metadata.ipub.customcss -%}", + "", + "", + "{% endif %}", + "{% endif %}", "", "", "", From 0dd502cb07520007b3e0fdfa7ef1acdce4ca8ad7 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 20 Jul 2020 13:04:45 +0100 Subject: [PATCH 06/23] move to github actions --- .github/workflows/tests.yml | 80 +++++++++++++++++++++++++++++++++++++ .gitignore | 3 ++ .vscode/settings.json | 2 +- 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..4fd84b2 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,80 @@ +name: continuous-integration + +on: [push, pull_request] + +jobs: + pre-commit: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e .[code_style] + - name: Run pre-commit + run: | + pre-commit run --all-files || ( git status --short ; git diff ; exit 1 ) + + + tests: + + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: [3.6, 3.8] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e .[tests] + + - name: Run pytest + run: | + pytest --cov=ipypublish --cov-report=xml --cov-report=term-missing + coverage xml + + - name: Upload to Codecov + if: matrix.python-version == 3.8 && matrix.os == 'ubuntu-latest' && github.repository == 'chrisjsewell/ipypublish' + uses: codecov/codecov-action@v1 + with: + name: ipypublish-pytests-py3.8 + flags: pytests + file: ./coverage.xml + fail_ci_if_error: true + + publish: + + name: Publish to PyPi + needs: [pre-commit, tests] + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v2 + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Build package + run: | + pip install wheel + python setup.py sdist bdist_wheel + - name: Publish + uses: pypa/gh-action-pypi-publish@v1.1.0 + with: + user: __token__ + password: ${{ secrets.PYPI_KEY }} diff --git a/.gitignore b/.gitignore index dd19e98..7a9ec5e 100644 --- a/.gitignore +++ b/.gitignore @@ -100,6 +100,9 @@ ENV/ # mypy .mypy_cache/ +# masOS +.DS_Store + # docs build docs/source/_build diff --git a/.vscode/settings.json b/.vscode/settings.json index 5708289..767599b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,7 +12,7 @@ "**/*.pyc": true, "**/__pycache__": true }, - "python.pythonPath": "/anaconda/envs/ipypublish_dev/bin/python", + "python.pythonPath": "/Users/chrisjsewell/opt/miniconda3/envs/ipypublish/bin/python", "restructuredtext.confPath": "${workspaceFolder}/docs/source", "restructuredtext.builtDocumentationPath": "${workspaceFolder}/docs/build/html", "restructuredtext.preview.scrollEditorWithPreview": false, From 169a8e6b64d0c350956987bf9ffb649bc4985557 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 20 Jul 2020 13:16:53 +0100 Subject: [PATCH 07/23] Update tests.yml --- .github/workflows/tests.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4fd84b2..55c6053 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,10 +9,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up Python 3.7 - uses: actions/setup-python@v1 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 with: - python-version: 3.7 + python-version: 3.8 - name: Install dependencies run: | python -m pip install --upgrade pip @@ -21,7 +21,6 @@ jobs: run: | pre-commit run --all-files || ( git status --short ; git diff ; exit 1 ) - tests: strategy: @@ -32,16 +31,24 @@ jobs: runs-on: ${{ matrix.os }} steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v1 with: python-version: ${{ matrix.python-version }} + - name: Install dependencies run: | python -m pip install --upgrade pip pip install -e .[tests] + - name: install pandoc + uses: r-lib/actions/setup-pandoc@v1 + with: + pandoc-version: '2.6' + - name: Run pytest run: | pytest --cov=ipypublish --cov-report=xml --cov-report=term-missing @@ -65,10 +72,10 @@ jobs: steps: - name: Checkout source uses: actions/checkout@v2 - - name: Set up Python 3.7 + - name: Set up Python 3.8 uses: actions/setup-python@v2 with: - python-version: 3.7 + python-version: 3.8 - name: Build package run: | pip install wheel From 2d7048e5f4e87cb0f0f718a4d7e61aded22738ff Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 20 Jul 2020 13:27:52 +0100 Subject: [PATCH 08/23] update versions --- .pre-commit-config.yaml | 4 ++++ setup.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c382d5c..be471c0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,6 +24,10 @@ repos: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace + + - repo: https://gitlab.com/pycqa/flake8 + rev: "3.7.9" + hooks: - id: flake8 - repo: https://github.com/psf/black diff --git a/setup.py b/setup.py index 6adcc2f..83bb4d9 100755 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ "pillow", "nbsphinx>=0.5,<0.6", "ipykernel", - "sphinx>=1.6", + "sphinx>=1.6,<3", "sphinxcontrib-bibtex", "texsoup<=0.1.4", }, From 2885919b13312c8a552a3fb8b30212092e970955 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 20 Jul 2020 13:35:08 +0100 Subject: [PATCH 09/23] skip latexmk tests --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 55c6053..8bbba30 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -51,7 +51,7 @@ jobs: - name: Run pytest run: | - pytest --cov=ipypublish --cov-report=xml --cov-report=term-missing + pytest --cov=ipypublish --cov-report=xml --cov-report=term-missing -k 'not requires_latexmk' coverage xml - name: Upload to Codecov From add6a0d56ece4a7c2026824df5d54a789e05469a Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 20 Jul 2020 13:38:50 +0100 Subject: [PATCH 10/23] Update test_postprocessors.py --- ipypublish/tests/test_postprocessors.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ipypublish/tests/test_postprocessors.py b/ipypublish/tests/test_postprocessors.py index 2154e6c..c92518d 100644 --- a/ipypublish/tests/test_postprocessors.py +++ b/ipypublish/tests/test_postprocessors.py @@ -1,8 +1,11 @@ import os +import pytest + from ipypublish.postprocessors.pdfexport import PDFExport from ipypublish.postprocessors.reveal_serve import RevealServer +@pytest.mark.requires_latexmk def test_pdf_export(temp_folder): tex_content = """ From ec5951997c725e4cd6ca28e3df7cd0354084b9e8 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 20 Jul 2020 14:05:32 +0100 Subject: [PATCH 11/23] add latex build --- .github/workflows/tests.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8bbba30..8056ffc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -49,11 +49,27 @@ jobs: with: pandoc-version: '2.6' - - name: Run pytest + - name: Install latex dependencies + if: matrix.os == 'ubuntu-latest' run: | - pytest --cov=ipypublish --cov-report=xml --cov-report=term-missing -k 'not requires_latexmk' + sudo apt-get -qq update + sudo apt-get install -y \ + texlive \ + texlive-xetex \ + texlive-latex-extra \ + texlive-lang-portuguese \ + latexmk \ + + - name: Run pytest with latexmk + if: matrix.os == 'ubuntu-latest' + run: | + pytest --cov=ipypublish --cov-report=xml --cov-report=term-missing coverage xml + - name: Run pytest without latexmk + if: matrix.os != 'ubuntu-latest' + run: pytest --cov=ipypublish --cov-report=term-missing -k 'not requires_latexmk' + - name: Upload to Codecov if: matrix.python-version == 3.8 && matrix.os == 'ubuntu-latest' && github.repository == 'chrisjsewell/ipypublish' uses: codecov/codecov-action@v1 From 0296478f3380efa2028f548ee674416674cee1be Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 20 Jul 2020 14:18:34 +0100 Subject: [PATCH 12/23] Update tests.yml --- .github/workflows/tests.yml | 68 ++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 19 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8056ffc..20872c8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,7 +13,7 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.8 - - name: Install dependencies + - name: Install python dependencies run: | python -m pip install --upgrade pip pip install -e .[code_style] @@ -39,7 +39,7 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Install dependencies + - name: Install python dependencies run: | python -m pip install --upgrade pip pip install -e .[tests] @@ -58,7 +58,7 @@ jobs: texlive-xetex \ texlive-latex-extra \ texlive-lang-portuguese \ - latexmk \ + latexmk - name: Run pytest with latexmk if: matrix.os == 'ubuntu-latest' @@ -79,25 +79,55 @@ jobs: file: ./coverage.xml fail_ci_if_error: true - publish: + nbpublish: + # needs: [tests] + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install python dependencies + run: | + python -m pip install --upgrade pip + pip install -e .[tests] + - name: install pandoc + uses: r-lib/actions/setup-pandoc@v1 + with: + pandoc-version: '2.6' + - name: Install latex dependencies + run: | + sudo apt-get -qq update + sudo apt-get install -y \ + texlive \ + texlive-xetex \ + texlive-latex-extra \ + texlive-lang-portuguese \ + latexmk + - name: run nbpublish + run: nbpublish -pdf --pdf-debug -log debug example/notebooks/Example.ipynb + + pypi: name: Publish to PyPi needs: [pre-commit, tests] if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') runs-on: ubuntu-latest steps: - - name: Checkout source - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Build package - run: | - pip install wheel - python setup.py sdist bdist_wheel - - name: Publish - uses: pypa/gh-action-pypi-publish@v1.1.0 - with: - user: __token__ - password: ${{ secrets.PYPI_KEY }} + - name: Checkout source + uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Build package + run: | + pip install wheel + python setup.py sdist bdist_wheel + - name: Publish + uses: pypa/gh-action-pypi-publish@v1.1.0 + with: + user: __token__ + password: ${{ secrets.PYPI_KEY }} From 22b82f194ac6077ae952a09650ed86643b52eb6a Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 20 Jul 2020 17:27:18 +0100 Subject: [PATCH 13/23] fix windows (release log handler) --- .github/workflows/tests.yml | 2 +- ipypublish/convert/main.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 20872c8..bc07144 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -80,7 +80,7 @@ jobs: fail_ci_if_error: true nbpublish: - # needs: [tests] + needs: [tests] runs-on: ubuntu-latest steps: - name: Checkout source diff --git a/ipypublish/convert/main.py b/ipypublish/convert/main.py index a41e42d..da7d71d 100755 --- a/ipypublish/convert/main.py +++ b/ipypublish/convert/main.py @@ -283,6 +283,7 @@ def logger(self): def _setup_logger(self, ipynb_name, outdir): root = logging.getLogger() + log_handlers = [] if self.log_to_stdout or self.log_to_file: # remove any existing handlers @@ -297,6 +298,7 @@ def _setup_logger(self, ipynb_name, outdir): slogger.setFormatter(formatter) slogger.propogate = False root.addHandler(slogger) + log_handlers.append(slogger) if self.log_to_file: # setup logging to file @@ -314,6 +316,9 @@ def _setup_logger(self, ipynb_name, outdir): flogger.setFormatter(formatter) flogger.propogate = False root.addHandler(flogger) + log_handlers.append(flogger) + + return log_handlers def __init__(self, config=None): """ @@ -372,7 +377,7 @@ def publish(self, ipynb_path, nb_node=None): else str(self.outpath) ) - self._setup_logger(ipynb_name, outdir) + log_handlers = self._setup_logger(ipynb_name, outdir) if not ipynb_path.exists() and not nb_node: handle_error( @@ -486,6 +491,12 @@ def publish(self, ipynb_path, nb_node=None): self.logger.info("process finished successfully") + # release log handlers + root_logger = logging.getLogger() + for handler in log_handlers: + handler.close() + root_logger.removeHandler(handler) + return { "outpath": outdir, "exporter": exporter, From 3d3450cd27e9e127b0369759354308b8db4fd92f Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 20 Jul 2020 20:33:41 +0100 Subject: [PATCH 14/23] add log handlers in a context --- .vscode/settings.json | 2 +- ipypublish/convert/main.py | 287 +++++++++++++++++++------------------ 2 files changed, 148 insertions(+), 141 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 767599b..24ba0f0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "editor.rulers": [ - 80, + 88, 120 ], "files.exclude": { diff --git a/ipypublish/convert/main.py b/ipypublish/convert/main.py index da7d71d..068b861 100755 --- a/ipypublish/convert/main.py +++ b/ipypublish/convert/main.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # import base64 +from contextlib import contextmanager from typing import List, Tuple, Union, Dict # noqa: F401 import logging import os @@ -280,45 +281,52 @@ def _create_default_pporder( def logger(self): return logging.getLogger("ipypublish") - def _setup_logger(self, ipynb_name, outdir): + @contextmanager + def _log_handlers(self, ipynb_name, outdir): root = logging.getLogger() + root_level = root.level log_handlers = [] - if self.log_to_stdout or self.log_to_file: - # remove any existing handlers - root.handlers = [] + try: root.setLevel(logging.DEBUG) - if self.log_to_stdout: - # setup logging to terminal - slogger = logging.StreamHandler(sys.stdout) - slogger.setLevel(getattr(logging, self.log_level_stdout.upper())) - formatter = logging.Formatter(self.log_stdout_formatstr) - slogger.setFormatter(formatter) - slogger.propogate = False - root.addHandler(slogger) - log_handlers.append(slogger) - - if self.log_to_file: - # setup logging to file - if self.log_file_path: - path = self.log_file_path - else: - path = os.path.join(outdir, ipynb_name + ".nbpub.log") - - if not os.path.exists(os.path.dirname(path)): - os.makedirs(os.path.dirname(path)) - - flogger = logging.FileHandler(path, "w") - flogger.setLevel(getattr(logging, self.log_level_file.upper())) - formatter = logging.Formatter(self.log_file_formatstr) - flogger.setFormatter(formatter) - flogger.propogate = False - root.addHandler(flogger) - log_handlers.append(flogger) - - return log_handlers + if self.log_to_stdout: + # setup logging to terminal + slogger = logging.StreamHandler(sys.stdout) + slogger.setLevel(getattr(logging, self.log_level_stdout.upper())) + formatter = logging.Formatter(self.log_stdout_formatstr) + slogger.setFormatter(formatter) + slogger.propogate = False + root.addHandler(slogger) + log_handlers.append(slogger) + + if self.log_to_file: + # setup logging to file + if self.log_file_path: + path = self.log_file_path + else: + path = os.path.join(outdir, ipynb_name + ".nbpub.log") + + if not os.path.exists(os.path.dirname(path)): + os.makedirs(os.path.dirname(path)) + + flogger = logging.FileHandler(path, "w") + flogger.setLevel(getattr(logging, self.log_level_file.upper())) + formatter = logging.Formatter(self.log_file_formatstr) + flogger.setFormatter(formatter) + flogger.propogate = False + root.addHandler(flogger) + log_handlers.append(flogger) + + yield + + finally: + + root.setLevel(root_level) + for handler in log_handlers: + handler.close() + root.removeHandler(handler) def __init__(self, config=None): """ @@ -377,125 +385,124 @@ def publish(self, ipynb_path, nb_node=None): else str(self.outpath) ) - log_handlers = self._setup_logger(ipynb_name, outdir) + with self._log_handlers(ipynb_name, outdir): - if not ipynb_path.exists() and not nb_node: - handle_error( - "the notebook path does not exist: {}".format(ipynb_path), - IOError, - self.logger, - ) - - # log start of conversion - self.logger.info( - "started ipypublish v{0} at {1}".format( - ipypublish.__version__, time.strftime("%c") - ) - ) - self.logger.info( - "logging to: {}".format(os.path.join(outdir, ipynb_name + ".nbpub.log")) - ) - self.logger.info("running for ipynb(s) at: {0}".format(ipynb_path)) - self.logger.info("with conversion configuration: {0}".format(self.conversion)) - - if nb_node is None and ipynb_ext in self.pre_conversion_funcs: - func = self.pre_conversion_funcs[ipynb_ext] - self.logger.info( - "running pre-conversion with: {}".format(inspect.getmodule(func)) - ) - try: - nb_node = func(ipynb_path) - except Exception as err: + if not ipynb_path.exists() and not nb_node: handle_error( - "pre-conversion failed for {}: {}".format(ipynb_path, err), - err, + "the notebook path does not exist: {}".format(ipynb_path), + IOError, self.logger, ) - # doesn't work with folders - # if (ipynb_ext != ".ipynb" and nb_node is None): - # handle_error( - # 'the file extension is not associated with any ' - # 'pre-converter: {}'.format(ipynb_ext), - # TypeError, self.logger) - - if nb_node is None: - # merge all notebooks - # TODO allow notebooks to remain separate - # (would require creating a main.tex with the preamble in etc ) - # Could make everything a 'PyProcess', - # with support for multiple streams - final_nb, meta_path = merge_notebooks( - ipynb_path, ignore_prefix=self.ignore_prefix + # log start of conversion + self.logger.info( + "started ipypublish v{0} at {1}".format( + ipypublish.__version__, time.strftime("%c") + ) ) - else: - final_nb, meta_path = (nb_node, ipynb_path) - - # validate the notebook metadata against the schema - if self.validate_nb_metadata: - nb_metadata_schema = read_file_from_directory( - get_module_path(schema), - "doc_metadata.schema.json", - "doc_metadata.schema", - self.logger, - interp_ext=True, + self.logger.info( + "logging to: {}".format(os.path.join(outdir, ipynb_name + ".nbpub.log")) + ) + self.logger.info("running for ipynb(s) at: {0}".format(ipynb_path)) + self.logger.info( + "with conversion configuration: {0}".format(self.conversion) ) - try: - jsonschema.validate(final_nb.metadata, nb_metadata_schema) - except jsonschema.ValidationError as err: - handle_error( - "validation of notebook level metadata failed: {}\n" - "see the doc_metadata.schema.json for full spec".format( - err.message - ), - jsonschema.ValidationError, - logger=self.logger, - ) - - # set text replacements for export configuration - replacements = { - self.meta_path_placeholder: str(meta_path), - self.files_folder_placeholder: "{}{}".format( - get_valid_filename(ipynb_name), self.folder_suffix - ), - } - - self.logger.debug("notebooks meta path: {}".format(meta_path)) - - # load configuration file - ( - exporter_cls, - jinja_template, - econfig, - pprocs, - pconfig, - ) = self._load_config_file(replacements) - - # run nbconvert - self.logger.info("running nbconvert") - exporter, stream, resources = self.export_notebook( - final_nb, exporter_cls, econfig, jinja_template - ) - # postprocess results - main_filepath = os.path.join(outdir, ipynb_name + exporter.file_extension) + if nb_node is None and ipynb_ext in self.pre_conversion_funcs: + func = self.pre_conversion_funcs[ipynb_ext] + self.logger.info( + "running pre-conversion with: {}".format(inspect.getmodule(func)) + ) + try: + nb_node = func(ipynb_path) + except Exception as err: + handle_error( + "pre-conversion failed for {}: {}".format(ipynb_path, err), + err, + self.logger, + ) + + # doesn't work with folders + # if (ipynb_ext != ".ipynb" and nb_node is None): + # handle_error( + # 'the file extension is not associated with any ' + # 'pre-converter: {}'.format(ipynb_ext), + # TypeError, self.logger) + + if nb_node is None: + # merge all notebooks + # TODO allow notebooks to remain separate + # (would require creating a main.tex with the preamble in etc ) + # Could make everything a 'PyProcess', + # with support for multiple streams + final_nb, meta_path = merge_notebooks( + ipynb_path, ignore_prefix=self.ignore_prefix + ) + else: + final_nb, meta_path = (nb_node, ipynb_path) + + # validate the notebook metadata against the schema + if self.validate_nb_metadata: + nb_metadata_schema = read_file_from_directory( + get_module_path(schema), + "doc_metadata.schema.json", + "doc_metadata.schema", + self.logger, + interp_ext=True, + ) + try: + jsonschema.validate(final_nb.metadata, nb_metadata_schema) + except jsonschema.ValidationError as err: + handle_error( + "validation of notebook level metadata failed: {}\n" + "see the doc_metadata.schema.json for full spec".format( + err.message + ), + jsonschema.ValidationError, + logger=self.logger, + ) + + # set text replacements for export configuration + replacements = { + self.meta_path_placeholder: str(meta_path), + self.files_folder_placeholder: "{}{}".format( + get_valid_filename(ipynb_name), self.folder_suffix + ), + } - for post_proc_name in pprocs: - proc_class = find_entry_point( - post_proc_name, "ipypublish.postprocessors", self.logger, "ipypublish" - ) - proc = proc_class(pconfig) - stream, main_filepath, resources = proc.postprocess( - stream, exporter.output_mimetype, main_filepath, resources + self.logger.debug("notebooks meta path: {}".format(meta_path)) + + # load configuration file + ( + exporter_cls, + jinja_template, + econfig, + pprocs, + pconfig, + ) = self._load_config_file(replacements) + + # run nbconvert + self.logger.info("running nbconvert") + exporter, stream, resources = self.export_notebook( + final_nb, exporter_cls, econfig, jinja_template ) - self.logger.info("process finished successfully") + # postprocess results + main_filepath = os.path.join(outdir, ipynb_name + exporter.file_extension) + + for post_proc_name in pprocs: + proc_class = find_entry_point( + post_proc_name, + "ipypublish.postprocessors", + self.logger, + "ipypublish", + ) + proc = proc_class(pconfig) + stream, main_filepath, resources = proc.postprocess( + stream, exporter.output_mimetype, main_filepath, resources + ) - # release log handlers - root_logger = logging.getLogger() - for handler in log_handlers: - handler.close() - root_logger.removeHandler(handler) + self.logger.info("process finished successfully") return { "outpath": outdir, From 49450babe015bdcc6a90d7453e4e341a2d7f5ed7 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 20 Jul 2020 20:51:44 +0100 Subject: [PATCH 15/23] fix windows path join --- ipypublish/convert/config_manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipypublish/convert/config_manager.py b/ipypublish/convert/config_manager.py index 397a0b7..9c68418 100644 --- a/ipypublish/convert/config_manager.py +++ b/ipypublish/convert/config_manager.py @@ -163,7 +163,7 @@ def load_template(template_key, template_dict): logger, interp_ext=False, ) - outline_name = os.path.join( + outline_name = "{0}/{1}".format( template_dict["outline"]["directory"], template_dict["outline"]["file"] ) else: @@ -174,7 +174,7 @@ def load_template(template_key, template_dict): logger, interp_ext=False, ) - outline_name = os.path.join( + outline_name = "{0}/{1}".format( template_dict["outline"]["module"], template_dict["outline"]["file"] ) From 6ec73f73b7c57a80de94a09e82512a8da68f96af Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Mon, 20 Jul 2020 21:19:47 +0100 Subject: [PATCH 16/23] fix doctest for windows --- ipypublish/preprocessors/latex_doc_links.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ipypublish/preprocessors/latex_doc_links.py b/ipypublish/preprocessors/latex_doc_links.py index 3be4edf..ad83e06 100644 --- a/ipypublish/preprocessors/latex_doc_links.py +++ b/ipypublish/preprocessors/latex_doc_links.py @@ -57,18 +57,18 @@ def extract_file_links(source, parent_path, redirect_path, replace_nonexistent=F Examples -------- >>> source = '''## Cell with Linked Image - ... ![test_image](subdir/logo_example.png) - ... a [test_link](other_doc#a-link)''' + ... ![test_image](subdir{0}logo_example.png) + ... a [test_link](other_doc#a-link)'''.format(os.path.sep) >>> src, rpaths, npaths = extract_file_links( - ... source, '/root/nb.ipynb', 'redirect', True) - >>> print(src) + ... source, '{0}root{0}nb.ipynb'.format(os.path.sep), 'redirect', True) + >>> print(src.replace(os.path.sep, '/')) ## Cell with Linked Image ![test_image](redirect/logo_example.png) a [test_link](redirect/other_doc#a-link) - >>> print(rpaths[0]) + >>> print(rpaths[0].replace(os.path.sep, '/')) /root/subdir/logo_example.png - >>> print(rpaths[1]) + >>> print(rpaths[1].replace(os.path.sep, '/')) /root/other_doc From 31b637752693c7f9f3f993bc1c9cfad2887b7e94 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Tue, 21 Jul 2020 00:11:04 +0100 Subject: [PATCH 17/23] skip doctest --- ipypublish/preprocessors/latex_doc_links.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ipypublish/preprocessors/latex_doc_links.py b/ipypublish/preprocessors/latex_doc_links.py index ad83e06..6aabf5b 100644 --- a/ipypublish/preprocessors/latex_doc_links.py +++ b/ipypublish/preprocessors/latex_doc_links.py @@ -57,18 +57,18 @@ def extract_file_links(source, parent_path, redirect_path, replace_nonexistent=F Examples -------- >>> source = '''## Cell with Linked Image - ... ![test_image](subdir{0}logo_example.png) - ... a [test_link](other_doc#a-link)'''.format(os.path.sep) + ... ![test_image](subdir/logo_example.png) + ... a [test_link](other_doc#a-link)''' >>> src, rpaths, npaths = extract_file_links( - ... source, '{0}root{0}nb.ipynb'.format(os.path.sep), 'redirect', True) - >>> print(src.replace(os.path.sep, '/')) + ... source, '/root/nb.ipynb', 'redirect', True) + >>> print(src) # doctest: +SKIP ## Cell with Linked Image ![test_image](redirect/logo_example.png) a [test_link](redirect/other_doc#a-link) - >>> print(rpaths[0].replace(os.path.sep, '/')) + >>> print(rpaths[0]) # doctest: +SKIP /root/subdir/logo_example.png - >>> print(rpaths[1].replace(os.path.sep, '/')) + >>> print(rpaths[1]) # doctest: +SKIP /root/other_doc From be3d8abfca10fe83ea495d7413beb12afce0a1b3 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Tue, 21 Jul 2020 00:31:55 +0100 Subject: [PATCH 18/23] Update latex_doc_links.py --- ipypublish/preprocessors/latex_doc_links.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ipypublish/preprocessors/latex_doc_links.py b/ipypublish/preprocessors/latex_doc_links.py index 6aabf5b..38c5ea1 100644 --- a/ipypublish/preprocessors/latex_doc_links.py +++ b/ipypublish/preprocessors/latex_doc_links.py @@ -56,19 +56,23 @@ def extract_file_links(source, parent_path, redirect_path, replace_nonexistent=F Examples -------- + >>> import os, pytest + >>> if os.name == 'nt': + ... pytest.skip() + >>> source = '''## Cell with Linked Image ... ![test_image](subdir/logo_example.png) ... a [test_link](other_doc#a-link)''' >>> src, rpaths, npaths = extract_file_links( ... source, '/root/nb.ipynb', 'redirect', True) - >>> print(src) # doctest: +SKIP + >>> print(src) ## Cell with Linked Image ![test_image](redirect/logo_example.png) a [test_link](redirect/other_doc#a-link) - >>> print(rpaths[0]) # doctest: +SKIP + >>> print(rpaths[0]) /root/subdir/logo_example.png - >>> print(rpaths[1]) # doctest: +SKIP + >>> print(rpaths[1]) /root/other_doc From e8b54a493f62c15f5be13c2ac0f2f08c8228cfc2 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Tue, 21 Jul 2020 00:47:56 +0100 Subject: [PATCH 19/23] skip windows tests --- ipypublish/tests/test_convert_markdown_cells.py | 3 +++ setup.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ipypublish/tests/test_convert_markdown_cells.py b/ipypublish/tests/test_convert_markdown_cells.py index 8f3326c..c1a8ca2 100644 --- a/ipypublish/tests/test_convert_markdown_cells.py +++ b/ipypublish/tests/test_convert_markdown_cells.py @@ -1,3 +1,4 @@ +import os import pytest @@ -18,6 +19,7 @@ def test_latex_and_pdf(ipynb_app): ipynb_app.assert_converted_equals_expected("latex_ipypublish_main.pandoc.2-2") +@pytest.mark.skipif(os.name == "nt", reason="skipping") @pytest.mark.ipynb("nb_markdown_cells") def test_sphinx_rst(ipynb_app): ipynb_app.run({"conversion": "sphinx_ipypublish_main"}) @@ -28,6 +30,7 @@ def test_sphinx_rst(ipynb_app): ipynb_app.assert_converted_equals_expected("sphinx_ipypublish_main.pandoc.2-6") +@pytest.mark.skipif(os.name == "nt", reason="skipping") @pytest.mark.ipynb("nb_with_mkdown_images") # out_to_temp=False def test_sphinx_rst_with_mkdown_images(ipynb_app): """ test a notebook with multiple images """ diff --git a/setup.py b/setup.py index 83bb4d9..a4fe108 100755 --- a/setup.py +++ b/setup.py @@ -48,7 +48,7 @@ "science": {"matplotlib", "numpy", "pandas", "sympy"}, "rtd": { "recommonmark>=0.5", - "pytest>=3.6", + "pytest>=4.4", "pillow", "numpy", "matplotlib", From 50ced2ae39c5389bda624ac263635d139c78fb2f Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Tue, 21 Jul 2020 01:11:44 +0100 Subject: [PATCH 20/23] change badges --- .github/workflows/tests.yml | 2 +- .pre-commit-config.yaml | 7 -- .travis.yml | 150 -------------------------------- README.md | 4 +- conda_dev_env.yaml | 2 +- docs/source/getting_started.Rmd | 10 +-- docs/source/index.rst | 8 +- 7 files changed, 12 insertions(+), 171 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bc07144..ae0cb8f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -112,7 +112,7 @@ jobs: pypi: name: Publish to PyPi - needs: [pre-commit, tests] + needs: [pre-commit, tests, nbpublish] if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') runs-on: ubuntu-latest steps: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index be471c0..3ced627 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -44,10 +44,3 @@ repos: language: system exclude: docs/build/* types: [rst] - - # - id: travis-linter - # name: Travis Lint - # entry: travis lint - # files: .travis.yml - # language: ruby - # additional_dependencies: ['travis'] diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 082d9f1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,150 +0,0 @@ -language: python -matrix: - include: - - os: linux - sudo: required - python: 3.6 - dist: trusty - env: TEST_TYPE="pre-commit" - - os: linux - sudo: required - python: 3.6 - dist: trusty - env: TEST_TYPE="rtd" - - os: linux - sudo: required - python: 3.6 - dist: trusty - env: TEST_TYPE="pytest" PYPI_DEPLOY=true - - os: linux - sudo: required - python: 3.7 - dist: xenial - env: TEST_TYPE="pytest" - - os: linux - sudo: required - python: 2.7 - dist: trusty - env: TEST_TYPE="pytest" - - os: linux - sudo: required - python: 3.5 - dist: trusty - env: TEST_TYPE="pytest" - # TODO this takes too long to install - # - os: osx - # language: generic - # env: TEST_TYPE="pytest" - # before_install: - # - travis_wait brew update - # # TODO currently by default python 2.7 is already installed (see https://github.com/travis-ci/travis-ci/issues/9929) - # # - brew install python3 - # # - brew upgrade python - # # - pip install virtualenv - # # - virtualenv env -p python3 - # # - source env/bin/activate - # # - alias pip="pip3" - # - brew install pandoc - # - brew upgrade wget - # - travis_retry sudo wget http://mirror.ctan.org/systems/mac/mactex/BasicTeX.pkg - # -O BasicTeX.pkg - # - sudo installer -pkg BasicTeX.pkg -target / - # - export PATH=$PATH:/usr/texbin:/Library/TeX/texbin - # - travis_retry sudo tlmgr update --self - # - travis_retry sudo tlmgr install babel - # - travis_retry sudo tlmgr install translations - # - travis_retry sudo tlmgr install latexmk - # - travis_retry sudo tlmgr install adjustbox - # - travis_retry sudo tlmgr install collectbox - # - travis_retry sudo tlmgr install ucs - # - travis_retry sudo tlmgr install enumitem - # - travis_retry sudo tlmgr install placeins - # - travis_retry sudo tlmgr install todonotes - # - travis_retry sudo tlmgr install chngcntr - # - travis_retry sudo tlmgr install doi - # - travis_retry sudo tlmgr install mdframed - # - travis_retry sudo tlmgr install cleveref - # - travis_retry sudo tlmgr install biblatex - # - travis_retry sudo tlmgr install needspace - # - travis_retry sudo tlmgr install collection-fontsrecommended - # # glossaries dependencies - # - travis_retry sudo tlmgr install glossaries # NB: for different languages glossaries- - # - travis_retry sudo tlmgr install mfirstuc # see https://tex.stackexchange.com/questions/268216/usepackageglossaries-wont-work-after-miktex-update-reinstallation - # - travis_retry sudo tlmgr install xfor - # - travis_retry sudo tlmgr install datatool - # - travis_retry sudo tlmgr install substr - allow_failures: - - os: linux - sudo: required - python: 2.7 - dist: trusty - env: TEST_TYPE="pytest" - - os: linux - sudo: required - python: 3.5 - dist: trusty - env: TEST_TYPE="pytest" - - os: osx - language: generic - env: TEST_TYPE="pytest" - -before_install: -# Pandoc -- | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - url="https://github.com/jgm/pandoc/releases/tag/2.6" - path=$(curl -L $url | grep -o '/jgm/pandoc/releases/download/.*-amd64\.deb') - downloadUrl="https://github.com$path" - file=${path##*/} - wget $downloadUrl && sudo dpkg -i $file - fi -# LaTeX -- | - if [[ "$TRAVIS_OS_NAME" == "linux" && "$TEST_TYPE" == "pytest" ]]; then - sudo apt-get -qq update - # sudo apt-get install -y pandoc is too old - sudo apt-get install -y texlive - sudo apt-get install -y texlive-xetex - sudo apt-get install -y texlive-latex-extra - sudo apt-get install -y texlive-lang-portuguese - # texlive-glossaries doesn't appear to be available - sudo wget http://mirrors.ctan.org/install/macros/latex/contrib/glossaries.tds.zip - sudo unzip glossaries.tds.zip -d ~/texmf/ - # need up-to-date koma-script, which isn't supplied with this version of debian - sudo wget http://mirrors.ctan.org/install/macros/latex/contrib/koma-script.tds.zip - sudo unzip koma-script.tds.zip -d ~/texmf/ - sudo apt-get install -y latexmk - if [[ "$TRAVIS_DIST" == "xenial" ]]; then - sudo apt-get install -y texlive-generic-recommended - fi - fi - -install: -- pip install -U pip setuptools wheel -- if [[ "$TEST_TYPE" == "pytest" ]]; then travis_wait pip install .[tests] ; fi -- if [[ "$TEST_TYPE" == "pytest" ]]; then pip install --quiet coveralls ; fi -- if [[ "$TEST_TYPE" == "pre-commit" ]]; then pip install -e .[code_style]; fi -- if [[ "$TEST_TYPE" == "rtd" ]]; then travis_wait pip install .[rtd] ; fi - -script: -- if [[ "$TEST_TYPE" == "pytest" ]]; then pytest -v --cov=ipypublish --cov-config .coveragerc --cov-report= ipypublish ; fi -- if [[ "$TEST_TYPE" == "pytest" ]]; then nbpublish -pdf --pdf-debug -log debug example/notebooks/Example.ipynb ; fi -- | - if [[ "$TEST_TYPE" == "pre-commit" ]]; then - pre-commit run --all-files || ( git status --short ; git diff ; exit 1 ) - fi -- if [[ "$TEST_TYPE" == "rtd" ]]; then cd docs; make ; fi - -after_success: -- if [[ "$TEST_TYPE" == "pytest" ]]; then coveralls ; fi - -deploy: - - provider: pypi - distributions: "bdist_wheel sdist" - user: cjsewell - password: - secure: OlCLGajz87wc/RPYMcMC9YrQjMgr6UVaadFQQWknz3ttT84+B0huFVaEbdnEBFNzPlKHlyO2Shz/3GBuBk+83rw997PWRZWCtuSsWgv5UxLm3inWCctQSzVBskHFL6lmQKb9rndUO7SnbX/2N2zuo1Ga2rqmuMLsifBn2An4+C4APCWB694aeAuECmbWMbx3L2YTtLvDL2SFTVtWki0e0bvUXJXVPeIJuKUaNQavaHdPKGjdJGG36+rh8bp4Cte4C2aOXUH3ovhk3VfzJiRDQSRQk2EoNHsB9js3kDsfX6Wn1zZIG4012KUX0tLpj+szI2lnhYeCRlW2t7Hfi/NOHEh1jQMQeuybIpHKmUjnwZC6BOYWT7UgJl2S5k4ZmjsiwTpuPcPmNca70VDpQ9THm4FZbfpLXFz6pBHyzOxQ7xdX2EW94fWv3dE87DSBU5Mu8fAMBTt2foOdRzKkAfQAbfa5TTnzJAf2uSUpGziPXsyaZnJWwSBUgEUvCeCPVaDLYDYSnzFHaQEOvdtkZwDcZ0oD5U6qW0/J6pzlvppWbEVCAPZ6Nos9o4ciO/JlNlEsgwVSgHceT7aFCvkhSKszIhzK0uk62PPgRhu6gZ9PHWQQJhVcL74lRXfsDqPR/sxA6xchHy1dXL+8J5MOtrMWOsk5HpInPKff7ErCzJOJHzg= - on: - branch: master - tags: true - condition: $PYPI_DEPLOY = true diff --git a/README.md b/README.md index fd98fb6..10c3dbd 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ from one or more Jupyter Notebooks. **Documentation**: [ipypublish.readthedocs.io](http://ipypublish.readthedocs.io) -[![CI Build](https://travis-ci.org/chrisjsewell/ipypublish.svg?branch=master)](https://travis-ci.org/chrisjsewell/ipypublish) -[![Coverage](https://coveralls.io/repos/github/chrisjsewell/ipypublish/badge.svg?branch=master)](https://coveralls.io/github/chrisjsewell/ipypublish?branch=master) +[![CI Status](https://github.com/chrisjsewell/ipypublish/workflows/continuous-integration/badge.svg)](https://github.com/chrisjsewell/ipypublish/actions) +[![Coverage Status](https://codecov.io/gh/chrisjsewell/ipypublish/branch/develop/graph/badge.svg)](https://codecov.io/gh/chrisjsewell/ipypublish) [![PyPI](https://img.shields.io/pypi/v/ipypublish.svg)](https://pypi.python.org/pypi/ipypublish/) [![DOI](https://zenodo.org/badge/96322423.svg)](https://zenodo.org/badge/latestdoi/96322423) [![Conda](https://anaconda.org/conda-forge/ipypublish/badges/version.svg)](https://anaconda.org/conda-forge/ipypublish) diff --git a/conda_dev_env.yaml b/conda_dev_env.yaml index 5c52c1e..e04f72b 100644 --- a/conda_dev_env.yaml +++ b/conda_dev_env.yaml @@ -30,7 +30,7 @@ dependencies: - tornado - traitlets # testing -- pytest >=3.6 +- pytest >=4.4 - pytest-regressions - nbsphinx - pillow diff --git a/docs/source/getting_started.Rmd b/docs/source/getting_started.Rmd index 7575559..69b3dac 100644 --- a/docs/source/getting_started.Rmd +++ b/docs/source/getting_started.Rmd @@ -169,13 +169,11 @@ $ nbpresent -f slides_ipypublish_nocode path/to/notebook.ipynb ## Troubleshooting -For installation issues, [Travis -CI](https://en.wikipedia.org/wiki/Travis_CI) is used to automatically -test updates against python 2.7 and 3.6, for both Linux and OSX, +For installation issues, GitHub Actions is used to automatically +test updates against multiple Python versions, for Linux, Windows and OSX, Therefore, to troubleshoot any installation/run issues, it is best to -first look at the [travis -config](https://github.com/chrisjsewell/ipypublish/blob/master/.travis.yml) -and [travis test runs](https://travis-ci.org/chrisjsewell/ipypublish) +first look at the [test workflow](https://github.com/chrisjsewell/ipypublish/blob/master/.github/workflows/tests.yml) +and [test runs](https://github.com/chrisjsewell/ipypublish/actions) for working configurations. The diff --git a/docs/source/index.rst b/docs/source/index.rst index 95ebe90..3369db7 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -109,10 +109,10 @@ Index and Search * :ref:`modindex` * :ref:`search` -.. |Build Status| image:: https://travis-ci.org/chrisjsewell/ipypublish.svg?branch=master - :target: https://travis-ci.org/chrisjsewell/ipypublish -.. |Coverage Status| image:: https://coveralls.io/repos/github/chrisjsewell/ipypublish/badge.svg?branch=master - :target: https://coveralls.io/github/chrisjsewell/ipypublish?branch=master +.. |Build Status| image:: https://github.com/chrisjsewell/ipypublish/workflows/continuous-integration/badge.svg + :target: https://github.com/chrisjsewell/ipypublish/actions +.. |Coverage Status| image:: https://codecov.io/gh/chrisjsewell/ipypublish/branch/develop/graph/badge.svg + :target: https://codecov.io/gh/chrisjsewell/ipypublish .. |PyPI| image:: https://img.shields.io/pypi/v/ipypublish.svg :target: https://pypi.python.org/pypi/ipypublish/ .. |DOI| image:: https://zenodo.org/badge/96322423.svg From cf4c24436991a28caaceb775ad17471b54bb0d30 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Tue, 21 Jul 2020 01:26:47 +0100 Subject: [PATCH 21/23] Update .readthedocs.yml --- .readthedocs.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 253d50b..b0b0791 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -4,15 +4,13 @@ conda: environment: docs/environment.yaml python: - version: 3.6 + version: 3.7 install: - method: pip path: . extra_requirements: - rtd -# default -# sphinx: -# builder: html -# configuration: conf.py -# fail_on_warning: true +sphinx: + builder: html + fail_on_warning: true From ed57fb68b51a9a75c5d7ebac9ce6f7e685e28896 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Tue, 21 Jul 2020 01:37:30 +0100 Subject: [PATCH 22/23] Update conf.py --- docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 5379e99..c99c3b0 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -284,7 +284,7 @@ def process_citations(app, doctree, docname): "bibtexparser": ("https://bibtexparser.readthedocs.io/en/master/", None), # 'docutils': ("https://docutils.readthedocs.io/en/sphinx-docs", None), # # TODO docutils intersphinx - "sphinx": ("http://www.sphinx-doc.org/en/latest/", None), + "sphinx": ("https://www.sphinx-doc.org/en/2.0/", None), } intersphinx_aliases = { From d320655b0397fdd1aac196abdc719d5e4ed02d00 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Tue, 21 Jul 2020 02:10:56 +0100 Subject: [PATCH 23/23] bump version --- docs/source/releases.rst | 22 +++++++++++++++------- ipypublish/__init__.py | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/docs/source/releases.rst b/docs/source/releases.rst index 42d7360..52f9b01 100644 --- a/docs/source/releases.rst +++ b/docs/source/releases.rst @@ -3,16 +3,24 @@ Releases ======== -.. attention:: - - A major API improvement occurred in ``v0.7.0``. - This has not changed the general user interface, - but anyone using custom converter plugins will be required to update them - (see :ref:`convert_from_old_api`) - Version 0.10 ------------ +v0.10.11 +~~~~~~~~ + +- Allow configuration of initial section numbering *via* notebook metadata: + - uses``toc.base_numbering`` as set by the toc2 notebook plugin + (thanks to @phelps-sg) +- Allow configuration of initial section numbering via notebook metadata + (thanks to @phelps-sg) +- Refactor testing and deployment: + - Move from Travis CI to GitHub Actions for CI and CD + - Introduce testing for Windows + - Ensure release of logging handlers after build finishes + - Move from Coveralls to Codecov for test coverage reporting + - Use RTD directly for docs CI, and make the build fail on warnings + v0.10.10 ~~~~~~~~ diff --git a/ipypublish/__init__.py b/ipypublish/__init__.py index 8b867ee..4afc2b1 100644 --- a/ipypublish/__init__.py +++ b/ipypublish/__init__.py @@ -1,3 +1,3 @@ from ipypublish.scripts import nb_setup # noqa: F401 -__version__ = "0.10.10" +__version__ = "0.10.11"