diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c20015b..219da3e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,18 +23,14 @@ jobs: - uses: actions/setup-python@v1 with: python-version: ${{ matrix.python-version }} - # https://github.com/actions/cache/blob/main/examples.md#using-a-script-to-get-cache-location - - id: pip-cache - run: python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)" - - uses: actions/cache@v1 - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} - restore-keys: | - ${{ runner.os }}-pip- + cache: pip - run: pip install .[test] - run: pip install "myst-parser${{ matrix.myst-parser-version }}" + # Run pytest - run: pytest -vv --cov sphinxcontrib + # Also try building the docs in the docs directory + - run: pip install sphinx_rtd_theme + - run: cd docs && make dirhtml - env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: coveralls --service=github diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7c70b64..66ede39 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,15 +11,7 @@ jobs: with: python-version: 3.6 architecture: x64 - # https://github.com/actions/cache/blob/main/examples.md#using-a-script-to-get-cache-location - - id: pip-cache - run: python -c "from pip._internal.locations import USER_CACHE_DIR; print('::set-output name=dir::' + USER_CACHE_DIR)" - - uses: actions/cache@v1 - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} - restore-keys: | - ${{ runner.os }}-pip- + cache: pip - run: pip install .[test] - run: flake8 . - run: isort . diff --git a/CHANGELOG.md b/CHANGELOG.md index 75bca55..4a2b06e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [0.3.1] - 2022-08-03 + +- Fix markdown related directives to work with myst-parser 0.18.0 + ## [0.3.0] - 2022-07-26 ### Added diff --git a/setup.py b/setup.py index 856530a..0c296dd 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='sphinxcontrib-opendataservices', - version='0.3.0', + version='0.3.1', author='Open Data Services', author_email='code@opendataservices.coop', packages=['sphinxcontrib'], diff --git a/sphinxcontrib/opendataservices.py b/sphinxcontrib/opendataservices.py index 3759604..f95526e 100644 --- a/sphinxcontrib/opendataservices.py +++ b/sphinxcontrib/opendataservices.py @@ -27,10 +27,12 @@ from myst_parser.parsers.mdit import create_md_parser # to_docutils was removed in myst-parser>=0.18. - def to_docutils(text): + def to_docutils(text, document=None): # Code is similar to MystParser.parse and myst_parser.parsers.docutils_.Parser.parse. parser = create_md_parser(MdParserConfig(), SphinxRenderer) - parser.options["document"] = make_document() + if not document: + document = make_document() + parser.options["document"] = document return parser.render(text) @@ -94,14 +96,14 @@ def run(self): title = filename pointed = resolve_pointer(json_obj, self.options['jsonpointer']) # Remove the items mentioned in exclude - if(self.options.get('exclude')): + if self.options.get('exclude'): for item in self.options['exclude'].split(","): try: del pointed[item.strip()] except KeyError: pass - if(self.options.get('include_only')): + if self.options.get('include_only'): for node in list(pointed): if not (node in self.options.get('include_only')): del pointed[node] @@ -181,13 +183,13 @@ def get_csv_data(self): with open(abspath) as fp: json_obj = json.load(fp, object_pairs_hook=OrderedDict) pointed = resolve_pointer(json_obj, self.options['jsonpointer']) - if(self.options.get('exclude')): + if self.options.get('exclude'): for item in self.options['exclude'].split(","): try: del pointed[item.strip()] except KeyError: pass - if(self.options.get('include_only')): + if self.options.get('include_only'): for node in list(pointed): if not (node in self.options.get('include_only')): del pointed[node]