Adding a bit of code to try and make generating the toc easier

To handle multiple folders, code mostly taken from existing adr cli tool.
Also added local adr paths to make adr new work well when in a subfolder
This commit is contained in:
Alan Alexander 2021-06-08 18:10:24 -07:00
Родитель 7f7ca17ce2
Коммит 1ffea5d217
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: FDAA08B4655132C1
7 изменённых файлов: 105 добавлений и 12 удалений

4
Makefile Normal file
Просмотреть файл

@ -0,0 +1,4 @@
gentoc:
./generate_toc.sh > TOC.md
default: gentoc

Просмотреть файл

@ -76,14 +76,15 @@ $ adr-viewer --help
Using adr-tools cli (adr):
### set adr-tools directory for team in question:
See the limitations of adr-tools notation above. You need to change `.adr-dir` to the team you want to work on.
```
$ echo "decisions/websre" > .adr-dir
```
To handle multiple teams we've made the table of contents generator work just on filenames.
As such you can generally treat each adr directory as independent from the point of view of the ADR CLI tool.
### create new adr proposal for your team:
This assumes someone has initialized a team or group folder for you previously.
If not, the info is below.
```
$ cd decisions/$team
$ adr new My Awesome Web SRE Team ADR
./0002-my-awesome-global-adr.md
# then add your info & go
@ -91,9 +92,16 @@ $ vi 0002-my-awesome-global-adr.md
```
### initialize a new team- or group-specific decisions directory:
You'll need a new folder for your team, feel free to add as needed.
You will need to force add the adr-dir, as we want to ignore it at the root of repo,
but it's nice to have, to make the init/new commands work well.
```
$ adr init decisions/my-new-team
decisions/my-new-team/0001-record-architecture-decisions.md
$ mkdir -p decisions/$team
$ cd decisions/$team
$ echo "." > .adr-dir
$ git add -f .adr-dir
$ vi decisions/my-new-team/0001-record-architecture-decisions.md # then add your info & go
$ cp -r decisions/websre/templates decisions/my-new-team # set up custom templates if you like
$ vi decisions/my-new-team/templates/template.md # edit that custom team template
@ -101,8 +109,9 @@ $ vi decisions/my-new-team/templates/template.md # edit that custom team templat
### generate whole repository Table of Contents:
```
$ adr generate toc > TOC.md
# need to add some recursion when using more than Web SRE Team decisions.
$ make gentoc
# this will run the custom script generate_toc.sh, and generate the table of contents into the TOC.md file
# commit this to git if you'd like.
```
For a cleaner presentation, adr-viewer (a python package) is being considered as part of the CI to generate static files for a website from this repository.

12
TOC.md
Просмотреть файл

@ -1,5 +1,11 @@
# Architecture Decision Records
* [1. Record architecture decisions](0001-record-architecture-decisions.md)
* [2. Web SRE Service Documentation](0002-web-sre-service-documentation.md)
* [3. Use EKS Cluster as Default Container Platform](0003-use-eks-cluster-as-default-container-platform.md)
## websre
* [1. Record architecture decisions](./decisions/websre/0001-record-architecture-decisions.md)
* [2. Web SRE Service Documentation](./decisions/websre/0002-web-sre-service-documentation.md)
* [3. Use EKS Cluster as Default Container Platform](./decisions/websre/0003-use-eks-cluster-as-default-container-platform.md)
## global
* [1. Record architecture decisions](./decisions/global/0001-record-architecture-decisions.md)

Просмотреть файл

@ -0,0 +1 @@
.

Просмотреть файл

@ -0,0 +1,27 @@
# 1. Record architecture decisions
Date: 2021-04-28
Scope: Web SRE Team
## Status
Accepted
## Context
We need to record the architectural decisions made for our team.
## Decision
We will use Architecture Decision Records, as discussed in our original proposal: https://docs.google.com/document/d/1pZlYCyXcZbmQq1O-g4BNJD1uZTjluYKkk7BSu2BwOGU/edit#
## Consequences
* add ADR proposal and review planning to our team planning meetings
* may slow down / stop immediately jumping into some projects to make time for proactive architectural review
## Resources
* originating JIRA ticket: https://jira.mozilla.com/browse/SE-1670
* The original proposal google doc: https://docs.google.com/document/d/1pZlYCyXcZbmQq1O-g4BNJD1uZTjluYKkk7BSu2BwOGU/edit#
* [Michael Nygard's article](http://thinkrelevance.com/blog/2011/11/15/documenting-architecture-decisions)

Просмотреть файл

@ -0,0 +1 @@
.

45
generate_toc.sh Executable file
Просмотреть файл

@ -0,0 +1,45 @@
#!/bin/bash
set -e
args=$(getopt i:o:p: $*)
set -- $args
link_prefix=./decisions/
eval "$(adr config)"
cat <<EOF
# Architecture Decision Records
EOF
if [ ! -z $intro ]
then
cat "$intro"
echo
fi
basedir=$(pwd -P)/decisions
for d in $(find $basedir -mindepth 1 -maxdepth 1 -type d)
do
if ! [[ $d -ef $basedir ]]; then
echo -e "\n\n## $(basename $d)"
for f in $(find $d -name '*.md'| grep -E "/[0-9]+-[^/]*\\.md" | sort)
do
title=$(head -1 "$f" | cut -c 3-)
link=${link_prefix}$(basename $d)/$(basename $f)
echo "* [$title]($link)"
done
fi
done
if [ ! -z $outro ]
then
echo
cat "$outro"
fi