-
-
Notifications
You must be signed in to change notification settings - Fork 227
Refactor: Separate data from markdown presentation layer #228
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
Draft
Copilot
wants to merge
3
commits into
main
Choose a base branch
from
copilot/refactor-awesome-list-style
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,105
−179
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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,67 @@ | ||
| name: Render README | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - 'data/**' | ||
| - 'scripts/render_readme.py' | ||
| pull_request: | ||
| paths: | ||
| - 'data/**' | ||
| - 'scripts/render_readme.py' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| render: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install pyyaml | ||
|
|
||
| - name: Validate YAML schema | ||
| run: python scripts/validate_data.py | ||
|
|
||
| - name: Render README.md | ||
| run: python scripts/render_readme.py | ||
|
|
||
| - name: Check for changes | ||
| id: check_changes | ||
| run: | | ||
| if git diff --quiet README.md; then | ||
| echo "changed=false" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "changed=true" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Commit and push if changed | ||
| if: steps.check_changes.outputs.changed == 'true' && github.event_name != 'pull_request' | ||
| run: | | ||
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
| git config --local user.name "github-actions[bot]" | ||
| git add README.md | ||
| git commit -m "docs: auto-render README.md from data" | ||
| git push | ||
|
|
||
| - name: Comment on PR if changes needed | ||
| if: steps.check_changes.outputs.changed == 'true' && github.event_name == 'pull_request' | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| github.rest.issues.createComment({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: '⚠️ README.md needs to be regenerated. Please run `python scripts/render_readme.py` and commit the changes.' | ||
| }) | ||
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,38 @@ | ||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| *$py.class | ||
| *.so | ||
| .Python | ||
| build/ | ||
| develop-eggs/ | ||
| dist/ | ||
| downloads/ | ||
| eggs/ | ||
| .eggs/ | ||
| lib/ | ||
| lib64/ | ||
| parts/ | ||
| sdist/ | ||
| var/ | ||
| wheels/ | ||
| *.egg-info/ | ||
| .installed.cfg | ||
| *.egg | ||
|
|
||
| # Virtual environments | ||
| venv/ | ||
| ENV/ | ||
| env/ | ||
|
|
||
| # IDEs | ||
| .vscode/ | ||
| .idea/ | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
| .DS_Store | ||
|
|
||
| # Temporary files | ||
| *.tmp | ||
| *.bak |
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,67 @@ | ||
| # Contributing | ||
|
|
||
| This repository uses a data-driven approach to maintain the list of C# Source Generators. | ||
|
|
||
| ## Structure | ||
|
|
||
| - **`data/repositories.yml`** - The single source of truth containing all repository information | ||
| - **`scripts/render_readme.py`** - Python script that generates README.md from the YAML data | ||
| - **`scripts/validate_data.py`** - Validation script to ensure data quality | ||
| - **`scripts/extract_data.py`** - Helper script to extract data from existing README (used during migration) | ||
|
|
||
| ## Making Changes | ||
|
|
||
| ### Adding a New Repository | ||
|
|
||
| 1. Edit `data/repositories.yml` | ||
| 2. Add your repository under the appropriate category: | ||
|
|
||
| ```yaml | ||
| categories: | ||
| your-category: | ||
| repositories: | ||
| - name: YourGenerator | ||
| url: https://github.com/yourusername/yourgenerator | ||
| description: Brief description of what your generator does | ||
| ``` | ||
|
|
||
| 3. Run validation: `python scripts/validate_data.py` | ||
| 4. Render README: `python scripts/render_readme.py` | ||
| 5. Commit both `data/repositories.yml` and `README.md` | ||
|
|
||
| ### Adding a New Category | ||
|
|
||
| 1. Edit `data/repositories.yml` | ||
| 2. Add your category: | ||
|
|
||
| ```yaml | ||
| categories: | ||
| your-new-category: | ||
| name: Your New Category Name | ||
| repositories: | ||
| - name: FirstRepo | ||
| url: https://github.com/... | ||
| description: ... | ||
| ``` | ||
|
|
||
| 3. Update the table of contents in the YAML file if needed | ||
| 4. Follow steps 3-5 from "Adding a New Repository" | ||
|
|
||
| ## Automation | ||
|
|
||
| The repository includes a GitHub Actions workflow (`.github/workflows/render-readme.yml`) that: | ||
|
|
||
| - **On Push**: Validates data and auto-generates README.md | ||
| - **On Pull Requests**: Validates data and comments if README needs regeneration | ||
|
|
||
| ## Validation | ||
|
|
||
| The validation script checks for: | ||
|
|
||
| - Valid GitHub URLs | ||
| - Required fields (name, url) | ||
| - Duplicate repositories | ||
| - Empty descriptions | ||
| - Proper YAML structure | ||
|
|
||
| Run `python scripts/validate_data.py` before committing to ensure data quality. |
Large diffs are not rendered by default.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # Testing the Refactored Structure | ||
|
|
||
| This document demonstrates how to use the new data-driven structure. | ||
|
|
||
| ## Quick Test | ||
|
|
||
| 1. **Validate the current data:** | ||
| ```bash | ||
| python scripts/validate_data.py | ||
| ``` | ||
|
|
||
| 2. **Render the README:** | ||
| ```bash | ||
| python scripts/render_readme.py | ||
| ``` | ||
|
|
||
| 3. **Add a new repository** (edit `data/repositories.yml`): | ||
| ```yaml | ||
| categories: | ||
| your-category: | ||
| repositories: | ||
| - name: NewGenerator | ||
| url: https://github.com/user/repo | ||
| description: Description of the generator | ||
| ``` | ||
|
|
||
| 4. **Validate and render:** | ||
| ```bash | ||
| python scripts/validate_data.py && python scripts/render_readme.py | ||
| ``` | ||
|
|
||
| ## Automated Workflow | ||
|
|
||
| When you push changes to `data/repositories.yml`: | ||
|
|
||
| 1. GitHub Actions runs validation | ||
| 2. If validation passes, README.md is automatically regenerated | ||
| 3. Changes are committed back to the repository | ||
|
|
||
| ## Local Development | ||
|
|
||
| Install dependencies: | ||
| ```bash | ||
| pip install -r requirements.txt | ||
| ``` | ||
|
|
||
| Run validation: | ||
| ```bash | ||
| python scripts/validate_data.py | ||
| ``` | ||
|
|
||
| Render README: | ||
| ```bash | ||
| python scripts/render_readme.py | ||
| ``` |
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
If you start reworking the repository, what about simplifying the steps for adding new libraries? GitHub allows react when the pull request is merged. We could use that to make users simply create a new PR with a URL to the GitHub repository. Then, we could parse the GitHub repository by the URL and automatically create a new readme.
In summary:
https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#running-your-pull_request-workflow-when-a-pull-request-merges
If you need help, I can help you write the scripts.