Skip to content
Open
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
51 changes: 51 additions & 0 deletions .github/workflows/update-sources-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This workflow will install and set up conda and gams, run ReEDS, and run tests
name: Update sources documentation

on:
pull_request:
paths:
- 'docs/sources.csv'
- 'docs/source/documentation_tools/generate_markdown.py'
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
update-sources-docs:
name: update sources-documentation.md
runs-on: ubuntu-latest
permissions:
contents: write # needs write permissions to push updated sources_documentation.md back to the PR branch
env:
REEDS_PATH: ${{ github.workspace }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 1
# for PRs, we need to check out the actual PR branch so we can push back to it
ref: ${{ github.event.pull_request.head.ref }}

- name: Set up Python 3.12
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.12"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install argparse

- name: Generate & commit sources_documentation.md
run: |
python docs/source/documentation_tools/generate_markdown.py -r "$REEDS_PATH"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add docs/sources_documentation.md
git diff --cached --quiet && echo "No changes to commit" || \
git commit -m "docs: regenerate sources_documentation.md [skip ci]" && git push
15 changes: 0 additions & 15 deletions docs/source/documentation_tools/README.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/source/documentation_tools/generate_markdown.bat

This file was deleted.

18 changes: 15 additions & 3 deletions docs/source/documentation_tools/generate_markdown.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
#!/usr/bin/env python
# coding: utf-8

# Note: this script does not need to be run manually,
# sources_documentation.md is updated automatically as part of the update-sources-docs.yaml workflow

# How to use this script to get an updated sources_documentation.md file:
# 1. update docs/sources.csv
# 2. from the docs/source/documentation_tools folder, run: python generate_markdown.py
# optional args:
# -g/--githubURL <base_url> Base URL prepended to file links in markdown.
# -r/--reedsPath <path> Path used to find sources.csv and write output.


# In[1]:

import os
Expand All @@ -10,7 +21,7 @@

def slugify(text: str) -> str:
"""
Convert a string to a stable anchor id for markdow.
Convert a string to a stable anchor id for markdown.
Lowercase, replace spaces and slashes with hyphens, remove special characters except hyphens, and collapse multiple hyphens into one.

Args:
Expand Down Expand Up @@ -180,8 +191,9 @@ def main():
reeds_path = os.path.dirname(os.path.dirname(os.path.dirname(current_path)))
reeds_path = reeds_path.replace("\\","/")

reeds_docs_path = os.path.join(reeds_path, "docs")

desc_file_path = os.path.join(reeds_path, desc_holder).replace("\\","/")
desc_file_path = os.path.join(reeds_docs_path, desc_holder).replace("\\","/")


#Dataframe to store the newly generated sources.csv data
Expand Down Expand Up @@ -220,7 +232,7 @@ def main():

#Generate separate readme for ReEDS 2.0 Sources files
main_readme_file = "sources_documentation.md"
main_readme_file_path = os.path.join(reeds_path, main_readme_file).replace("\\","/")
main_readme_file_path = os.path.join(reeds_docs_path, main_readme_file).replace("\\","/")

#Open markdown file for entries
with open(main_readme_file_path, "w") as main_file:
Expand Down
2 changes: 0 additions & 2 deletions docs/source/documentation_tools/generate_markdown.sh

This file was deleted.

248 changes: 0 additions & 248 deletions docs/source/documentation_tools/generate_new_sources.py

This file was deleted.

7 changes: 0 additions & 7 deletions docs/source/documentation_tools/generate_sources_md_file.bat

This file was deleted.

8 changes: 0 additions & 8 deletions docs/source/documentation_tools/generate_sources_md_file.sh

This file was deleted.

Loading
Loading