Repository navigation
Move inputs documentation from sources.csv to inputs/*/README.md
#157
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
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
b9a5089
add readmes for input folders and fill out with information in source…
kennedy-mindermann d0ee7ae
add missing file to readme
kennedy-mindermann 07cf9e9
add script to compile inputs.md from the inputs/*/readme.md files
kennedy-mindermann 05e9a27
update formatting of readmes
kennedy-mindermann a0ee7bb
update script to not have duplicate headers
kennedy-mindermann e1341a1
merge main into km/source-documentation
kennedy-mindermann 910841e
update some links and fix spelling errors
kennedy-mindermann 56744b8
update formatting
kennedy-mindermann e3ac86c
remove input file records from sources.csv, add new dollar year file,…
kennedy-mindermann d49df6e
update readme
kennedy-mindermann e768cdf
Merge branch 'main' into km/source-documentation
kennedy-mindermann c98a334
formatting updates
kennedy-mindermann c620e35
remove the old generate_markdown script
kennedy-mindermann a72bf8c
Merge branch 'main' into km/source-documentation
kennedy-mindermann 6340034
delete sources_documentation.md
kennedy-mindermann 09ff17c
add get_source_deflator_map function back into copy_files
kennedy-mindermann 02dce1e
merge main into km/source-documentation
9dcff00
merge main into km/source-documentation
kennedy-mindermann c373232
fix copy_files
kennedy-mindermann 09a43f7
Merge branch 'main' into km/source-documentation
kennedy-mindermann de4c80a
Merge branch 'main' into km/source-documentation
kennedy-mindermann b32b572
Merge branch 'main' into km/source-documentation
kennedy-mindermann 0c496d3
updates in response to pr comments
kennedy-mindermann 77fe9df
remove get_source_deflator_map
kennedy-mindermann 5414bbe
Merge branch 'main' into km/source-documentation
kennedy-mindermann 6e957b5
Update inputs/canada_imports/README.md
kennedy-mindermann 02b4d5e
Update inputs/canada_imports/README.md
kennedy-mindermann 4f5e0cf
Update inputs/sets/README.md
kennedy-mindermann 7f33332
Update inputs/consume/README.md
kennedy-mindermann faa0612
Update inputs/canada_imports/README.md
kennedy-mindermann 234cff3
Update inputs/canada_imports/README.md
kennedy-mindermann 1429dae
Merge branch 'main' into km/source-documentation
kennedy-mindermann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| import argparse | ||
| import os | ||
| from pathlib import Path | ||
|
|
||
| def _collect_input_readmes(inputs_root: Path) -> list[Path]: | ||
| readmes = [] | ||
| for child in sorted(inputs_root.iterdir(), key=lambda p: p.name.casefold()): | ||
| if not child.is_dir(): | ||
| continue | ||
| readme = child / "README.md" | ||
| if readme.exists(): | ||
| readmes.append(readme) | ||
| return readmes | ||
|
|
||
|
|
||
| def _write_inputs_md(output_path: Path, readmes: list[Path]) -> None: | ||
| lines = [] | ||
| lines.append("# Inputs Documentation") | ||
| lines.append("") | ||
| lines.append( | ||
| "This page aggregates documentation from each folder README under the inputs directory." | ||
| ) | ||
| lines.append("") | ||
| lines.append("## Table of Contents") | ||
| lines.append("") | ||
|
|
||
| for readme in readmes: | ||
| folder = readme.parent.name | ||
| lines.append(f"- [inputs/{folder}](#inputs{folder})") | ||
|
|
||
| # Do not add an additional markdown section header here. | ||
| # Each included README already contains its own heading. | ||
| for readme in readmes: | ||
| folder = readme.parent.name | ||
| include_rel = os.path.relpath(readme, output_path.parent).replace(os.sep, "/") | ||
| lines.append("") | ||
| lines.append(f"<a id='inputs{folder}'></a>") | ||
| lines.append("") | ||
| lines.append("```{include} " + include_rel) | ||
| lines.append("```") | ||
|
|
||
| output_path.write_text("\n".join(lines) + "\n", encoding="utf-8") | ||
|
|
||
|
|
||
| def main(app=None): | ||
| # If called from Sphinx, app is provided; otherwise support optional CLI usage. | ||
| if app is None: | ||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument( | ||
| "--reedsPath", | ||
| "-r", | ||
| type=str, | ||
| default="", | ||
| help="Path to ReEDS repository root", | ||
| ) | ||
| args = parser.parse_args() | ||
| if args.reedsPath: | ||
| repo_root = Path(args.reedsPath).resolve() | ||
| else: | ||
| # docs/scripts/generate_inputs_markdown.py -> repo root is two levels up. | ||
| repo_root = Path(__file__).resolve().parents[2] | ||
| else: | ||
| repo_root = Path(app.srcdir).resolve().parents[1] | ||
|
|
||
| inputs_root = repo_root / "inputs" | ||
| docs_source_root = repo_root / "docs" / "source" | ||
| output_path = docs_source_root / "inputs.md" | ||
|
|
||
| readmes = _collect_input_readmes(inputs_root) | ||
| _write_inputs_md(output_path, readmes) | ||
|
|
||
| print("inputs.md has been updated from inputs/*/README.md files") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
This file was deleted.
Oops, something went wrong.
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about bringing the function code down to here instead of keeping it above in the functions? That seems slightly more intuitive to me, but maybe there is a value to keeping it as a function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see value in keeping the main function smaller, and having this as a separate function makes it a little more digestible imo. Happy to reconsider if you feel strongly, but I'd lean toward leaving it separate.