Skip to content

Commit

Permalink
Merge pull request #38 from OpenDataServices/fix-markdown
Browse files Browse the repository at this point in the history
Fix markdown directives
  • Loading branch information
Bjwebb authored Aug 4, 2022
2 parents 5d5c7e1 + bd76884 commit 554108a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 25 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 1 addition & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='sphinxcontrib-opendataservices',
version='0.3.0',
version='0.3.1',
author='Open Data Services',
author_email='[email protected]',
packages=['sphinxcontrib'],
Expand Down
14 changes: 8 additions & 6 deletions sphinxcontrib/opendataservices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 554108a

Please sign in to comment.