Preserve commits and formatting of yaml in docs#1514
Open
amgebauer wants to merge 1 commit into4C-multiphysics:mainfrom
Open
Preserve commits and formatting of yaml in docs#1514amgebauer wants to merge 1 commit into4C-multiphysics:mainfrom
amgebauer wants to merge 1 commit into4C-multiphysics:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR replaces PyYAML with ruamel.yaml to preserve comments and formatting in YAML documentation files. The changes include:
- Using ruamel.yaml with the
ruamel.yaml.stringplugin for rendering YAML in documentation - Using the fast
load_yamlutility fromfour_c_common_utils.iofor metadata loading where comment preservation is not needed - Updating dependencies in build-requirements.txt
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| utilities/four_c_python/src/four_c_documentation/render.py | Replaced PyYAML imports with ruamel.yaml for input file loading and dumping; switched metadata loading to use the fast load_yaml utility |
| utilities/four_c_python/build-requirements.txt | Replaced pyyaml dependency with ruamel.yaml and ruamel.yaml.string packages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| """Returns a string of the yaml file in the given filetype. | ||
| As of now I can return markdown and restructuredText code blocks. | ||
| """ | ||
| yaml = YAML(typ=["safe", "string"]) |
There was a problem hiding this comment.
The typ parameter should be a single string value, not a list. For the dump_to_string method to work, you need to use typ='safe' since ruamel.yaml.string is installed in the requirements. The correct syntax is:
yaml = YAML(typ='safe')The list syntax typ=["safe", "string"] is not valid for the YAML constructor.
Suggested change
| yaml = YAML(typ=["safe", "string"]) | |
| yaml = YAML(typ="safe") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following @gilrrei comment in #1505 (comment)
@gilrrei What do you think using ruaml to preserve formatting and comments for the input file?
I replaced pyyaml with our fast
load_yamlfor all other cases.