Skip to content

Commit

Permalink
Update yaml loading method
Browse files Browse the repository at this point in the history
  • Loading branch information
brynpickering committed Dec 22, 2023
1 parent 9558720 commit 28e931a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions doc/helpers/generate_readable_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from typing import Union

import jsonschema2md
import yaml
import ruamel.yaml


def schema_to_md(
Expand All @@ -28,8 +28,8 @@ def schema_to_md(
parser = jsonschema2md.Parser()
parser.tab_size = 2

with Path(path_to_schema).open("r") as f_schema:
schema = yaml.safe_load(f_schema)
yaml = ruamel.yaml.YAML(typ="safe")
schema = yaml.load(Path(path_to_schema).read_text())

lines = parser.parse_schema(schema)
lines = customise_markdown(lines)
Expand Down
6 changes: 4 additions & 2 deletions docs/scripts/generate_custom_math_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pathlib import Path

import mkdocs_gen_files
import ruamel.yaml as yaml
import ruamel.yaml

CUSTOM_MATH_PATH = "docs/custom_math"
CUSTOM_MATH_DOC_FILE = "_autogenerated/custom_math_examples.md"
Expand Down Expand Up @@ -59,7 +59,9 @@ def process_file(path):
comment_, yaml_ = text.split("# ---", 1)

comment_yaml_block = "\n".join(i.removeprefix("#") for i in comment_.split("\n"))
comment_yaml = yaml.safe_load(StringIO(comment_yaml_block))

yaml = ruamel.yaml.YAML(typ="safe")
comment_yaml = yaml.load(StringIO(comment_yaml_block))

title = comment_yaml.get("title", "")
description = comment_yaml.get("description", "")
Expand Down
1 change: 0 additions & 1 deletion requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ mkdocs-jupyter
mkdocs-macros-plugin
mkdocstrings-python
mkdocs-material >= 9.5
pip
typing-extensions

0 comments on commit 28e931a

Please sign in to comment.