Merge pull request #511 from zmitchell/this-month-in-nix-docs

This commit is contained in:
Valentin Gagarin 2023-04-07 00:05:18 +02:00 committed by GitHub
commit 00da03358f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 108 additions and 0 deletions

View File

@ -0,0 +1,14 @@
# This Month in Nix Docs
This is a script and template for compiling "This Month in Nix Docs". The process is semi-automated. The script queries a collection of Nix repositories, looking for merged PRs with documentation-related labels, RFCs (you have to look through these manually), and tracking issues in this repository.
A new post is created via:
```
$ ./new-post.sh <from YYYY-MM-DD> <to YYYY-MM-DD> > new-post.md
```
After this invocation a template post (`new-post.md`) will be filled out with the GitHub query results formatted as markdown at the end of the file.
There is some post-processing requried:
- Fill in the number and year/month at the top of the post.
- Manually check the RFCs for relevance
- Remove the "Tracking Issues" section, it's there for your convenience while writing.

View File

@ -0,0 +1,94 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p bash gh
set -euo pipefail
if [ $# -eq 0 ]; then
echo "Usage: query-prs.sh <from YYYY-MM-DD> <to YYYY-MM-DD>"
exit 1
fi
from_date="$1"
to_date="$2"
pr_fields="number,title,author,url"
pr_template="{{range .}}- [#{{.number}}]({{.url}}) {{.title}} ([@{{.author.login}}](https://github.com/{{.author.login}})){{printf \"\n\"}}{{end}}"
tracking_issue_template="{{range .}}- [#{{.number}}]({{.url}}) {{.title}}{{printf \"\n\"}}{{end}}"
# Lists the PRs merged from a repository between certain dates, optionally filtered by labels
list_merged_prs() {
if [ $# -gt 1 ]; then
repo="$1"
labels="$2"
gh pr list -R "$repo" --search "is:merged merged:$from_date..$to_date label:\"$labels\"" --json "$pr_fields" --template "$pr_template"
else
repo="$1"
gh pr list -R "$repo" --search "is:merged merged:$from_date..$to_date" --json "$pr_fields" --template "$pr_template"
fi
}
# Lists the PRs opened on a repository
list_opened_prs() {
if [ $# -gt 1 ]; then
repo="$1"
labels="$2"
gh pr list -R "$repo" --search "is:unmerged created:$from_date..$to_date label:\"$labels\"" --json "$pr_fields" --template "$pr_template"
else
repo="$1"
gh pr list -R "$repo" --search "is:unmerged created:$from_date..$to_date" --json "$pr_fields" --template "$pr_template"
fi
}
# Lists all of the tracking issues opened on nix.dev within the specified dates
list_new_tracking_issues() {
gh issue list -R "nixos/nix.dev" --search "created:$from_date..$to_date label:tracking" --json "$pr_fields" --template "$tracking_issue_template"
}
cat << EOF
# This Month in Nix Docs - #**NUMBER** - **MONTH** **YEAR**
## Community
The Documentation Team can be found in a number of places. Check the [Documentation Team page](https://nixos.org/community/teams/documentation.html) and drop in if you'd like to contribute!
## Projects
## RFCs
## Documentation PRs Merged
# AUTOGENERATED
EOF
echo "## PRs"
echo
echo "### NixOS/nix"
list_merged_prs "nixos/nix" "documentation"
echo
echo "### NixOS/nixpkgs"
list_merged_prs "nixos/nixpkgs" "6.topic: documentation"
echo
echo "### NixOS/nix-pills"
list_merged_prs "nixos/nix-pills"
echo
echo "### NixOS/nix.dev"
list_merged_prs "nixos/nix.dev"
echo
echo "## RFCs"
echo
echo "### Opened (manually check for relevance)"
list_opened_prs "nixos/rfcs"
echo
echo "### Accepted (manually check for relevance)"
list_merged_prs "nixos/rfcs"
echo
echo "## New Tracking Issues"
list_new_tracking_issues
echo