Skip to content

Commit

Permalink
Fix usage of latest ruamel.yaml (#84)
Browse files Browse the repository at this point in the history
* Fix usage of latest ruamel.yaml

* fix unused import

* Update doc_builds.yml

* Update doc_builds.yml
  • Loading branch information
rly authored Oct 26, 2023
1 parent c1552c6 commit efc983a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/doc_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ jobs:
cd hdmf-common-schema
python -m pip install -r requirements-doc.txt
- name: Install the current hdmf-docutils
run: |
pip uninstall hdmf-docutils --yes
pip install .
- name: Build HDMF-Common-Schema Docs
run: |
cd hdmf-common-schema
Expand All @@ -35,6 +40,11 @@ jobs:
cd nwb-schema
python -m pip install -r requirements-doc.txt
- name: Install the current hdmf-docutils
run: |
pip uninstall hdmf-docutils --yes
pip install .
- name: Build NWB-Schema Docs
run: |
cd nwb-schema
Expand Down
17 changes: 7 additions & 10 deletions hdmf_docutils/doctools/rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,17 +288,14 @@ def spec_to_yaml(spec):
:return: YAML string for the current specification
"""
import json
import sys

try:
from ruamel import yaml
except ImportError:
import yaml
from ruamel.yaml import YAML
from ruamel.yaml.compat import StringIO
clean_spec = json.loads(json.dumps(spec, sort_keys=True, indent=4, separators=(',', ': ')))
if sys.version_info[0] == 3:
return yaml.dump(clean_spec, default_flow_style=False)
else:
return yaml.safe_dump(clean_spec, default_flow_style=False)
yaml = YAML(pure=True)
yaml.default_flow_style = False
stream = StringIO()
yaml.dump(clean_spec, stream)
return stream.getvalue()

def add_spec(self, spec):
"""
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
'pillow',
'sphinx',
'sphinx-gallery',
'sphinx_rtd_theme'
'sphinx_rtd_theme',
'ruamel.yaml'
],
'setup_requires': 'pytest-runner',
'packages': find_packages(),
Expand Down

0 comments on commit efc983a

Please sign in to comment.