Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix usage of latest ruamel.yaml #84

Merged
merged 4 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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