Skip to content

Commit

Permalink
Update to MADR 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
snisnisniksonah committed Jun 14, 2018
1 parent 9a0fd01 commit c1ffa52
Show file tree
Hide file tree
Showing 22 changed files with 166 additions and 141 deletions.
16 changes: 14 additions & 2 deletions src/_adr_generate_graph
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ eval "$($(dirname $0)/adr-config)"


link_extension=.html

template_type=$("$adr_bin_dir/_adr_type")
while getopts e: arg
do
case "$arg" in
Expand All @@ -45,7 +45,7 @@ shift $((OPTIND-1))


function index() {
basename "$1" | sed -e 's/-.*//' | sed -e 's/^0*//'
basename "$1" | sed -e 's/-.*//' | sed -e 's/^0//' | sed -e 's/^0//' | sed -e 's/^0//'
}

echo "digraph {"
Expand All @@ -57,11 +57,23 @@ do
title=$("$adr_bin_dir/_adr_title" $f)

echo " _$n [label=\"$title\"; URL=\"$(basename $f .md)${link_extension}\"]"
case $template_type in
"")
if [ $n -gt 1 ]
then
echo " _$(($n - 1)) -> _$n [style=\"dotted\"];"
fi

"$adr_bin_dir/_adr_links" "$f" | sed -E -e 's/^([0-9]+)=(.+)$/ _'"$n"' -> _\1 [label="\2"]/'
;;
madr)
if [ $n -gt 0 ]
then
echo " _$(($n - 1)) -> _$n [style=\"dotted\"];"
fi

"$adr_bin_dir/_adr_links" "$f" | sed -E -e 's/^([0-9]+)=(.+)$/ _'"$n"' -> _\1 [label="\2"]/'
;;
esac
done
echo "}"
25 changes: 19 additions & 6 deletions src/adr-new
Original file line number Diff line number Diff line change
Expand Up @@ -102,26 +102,38 @@ then
exit 1
fi

#newnum=0

if [ -d $dstdir ]
then
maxid=$(ls $dstdir | grep -Eo '^[0-9]+' | sed -e 's/^0*//' | sort -rn | head -1)
filecount=$(ls $dstdir | grep -Eo '^[0-9]+' | wc -l)
maxid=$(ls $dstdir | grep -Eo '^[0-9]+' | sed -e 's/^0//' | sed -e 's/^0//'| sed -e 's/^0//' | sort -rn | head -1)
newnum=$(($maxid + 1))
if [ -z $maxid ]
then
newnum_madr=0
else
newnum_madr=$(($maxid + 1))
fi
else
newnum=1
newnum_madr=0
fi

newid=$(printf "%04d" $newnum)
if [ -z $template_type ]
then
newid=$(printf "%04d" $newnum)
else
newid=$(printf "%04d" $newnum_madr)
fi
slug=$(echo -n $title | tr -Ccs [:alnum:] - | tr [:upper:] [:lower:] | sed -e 's/[^[:alnum:]]*$//' -e 's/^[^[:alnum:]]*//')
dstfile=$dstdir/$newid-$slug.md
date=${ADR_DATE:-$(date +%Y-%m-%d)}

mkdir -p $dstdir

type=$("$adr_bin_dir/_adr_type")

tempfile=$dstdir/.tempfile

case $type in
case $template_type in
"")
cat $template | sed \
-e "s|NUMBER|$newnum|" \
Expand All @@ -139,6 +151,7 @@ case $type in
;;
esac

type=$("$adr_bin_dir/_adr_type")
if [ -z $type ]
then
type_suffix=""
Expand Down
6 changes: 3 additions & 3 deletions src/init-madr.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ Which format and structure should these records follow?

## Considered Options

* [MADR](https://adr.github.io/madr/) 2.0.3 - The Markdown Architectural Decision Records
* [MADR](https://adr.github.io/madr/) 2.1.0 - The Markdown Architectural Decision Records
* [Michael Nygard's template](http://thinkrelevance.com/blog/2011/11/15/documenting-architecture-decisions) - The first incarnation of the term "ADR"
* [Sustainable Architectural Decisions](https://www.infoq.com/articles/sustainable-architectural-design-decisions) - The Y-Statements
* Other templates listed at <https://github.com/joelparkerhenderson/architecture_decision_record>
* Formless - No conventions for file format and structure

## Decision Outcome

Chosen option: "MADR 2.0.3", because
Chosen option: "MADR 2.1.0", because
* Implicit assumptions should be made explicit.
Design documentation is important to enable people understanding the decisions later on.
See also [A rational design process: How and why to fake it](https://doi.org/10.1109/TSE.1986.6312940).
* The MADR format is lean and fits our development style.
* The MADR structure is comprehensible and facilitates usage & maintenance.
* The MADR project is vivid.
* Version 2.0.3 is the latest one available when starting to document ADRs.
* Version 2.1.0 is the latest one available when starting to document ADRs.
4 changes: 2 additions & 2 deletions src/template-madr.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ Technical Story: [description | ticket/issue URL] <!-- optional -->

Chosen option: "[option 1]", because [justification. e.g., only option, which meets k.o. criterion decision driver | which resolves force force | … | comes out best (see below)].

Positive Consequences: <!-- optional -->
### Positive Consequences: <!-- optional -->
* [e.g., improvement of quality attribute satisfaction, follow-up decisions required, …]
*

Negative consequences: <!-- optional -->
### Negative consequences: <!-- optional -->
* [e.g., compromising quality attribute, follow-up decisions required, …]
*

Expand Down
10 changes: 5 additions & 5 deletions tests/create-first-record-madr.expected
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
adr init docs madr
docs/0001-record-architecture-decisions.md
docs/0000-record-architecture-decisions.md
adr new The First Decision
docs/0002-the-first-decision.md
cat docs/0002-the-first-decision.md
docs/0001-the-first-decision.md
cat docs/0001-the-first-decision.md
# The First Decision

* Status: Accepted
Expand Down Expand Up @@ -32,11 +32,11 @@ Technical Story: [description | ticket/issue URL] <!-- optional -->

Chosen option: "[option 1]", because [justification. e.g., only option, which meets k.o. criterion decision driver | which resolves force force | … | comes out best (see below)].

Positive Consequences: <!-- optional -->
### Positive Consequences: <!-- optional -->
* [e.g., improvement of quality attribute satisfaction, follow-up decisions required, …]
* …

Negative consequences: <!-- optional -->
### Negative consequences: <!-- optional -->
* [e.g., compromising quality attribute, follow-up decisions required, …]
* …

Expand Down
2 changes: 1 addition & 1 deletion tests/create-first-record-madr.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
adr init docs madr
adr new The First Decision
cat docs/0002-the-first-decision.md
cat docs/0001-the-first-decision.md
20 changes: 10 additions & 10 deletions tests/create-multiple-records-madr.expected
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
adr init docs madr
docs/0001-record-architecture-decisions.md
docs/0000-record-architecture-decisions.md
adr new First Decision
docs/0002-first-decision.md
docs/0001-first-decision.md
adr new Second Decision
docs/0003-second-decision.md
docs/0002-second-decision.md
adr new Third Decision
docs/0004-third-decision.md
docs/0003-third-decision.md
ls docs
0001-record-architecture-decisions.md
0002-first-decision.md
0003-second-decision.md
0004-third-decision.md
head -8 docs/0003-second-decision.md
0000-record-architecture-decisions.md
0001-first-decision.md
0002-second-decision.md
0003-third-decision.md
head -8 docs/0002-second-decision.md
# Second Decision

* Status: Accepted
Expand All @@ -20,7 +20,7 @@ head -8 docs/0003-second-decision.md

Technical Story: [description | ticket/issue URL] <!-- optional -->

head -8 docs/0004-third-decision.md
head -8 docs/0003-third-decision.md
# Third Decision

* Status: Accepted
Expand Down
4 changes: 2 additions & 2 deletions tests/create-multiple-records-madr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ adr new First Decision
adr new Second Decision
adr new Third Decision
ls docs
head -8 docs/0003-second-decision.md
head -8 docs/0004-third-decision.md
head -8 docs/0002-second-decision.md
head -8 docs/0003-third-decision.md
12 changes: 6 additions & 6 deletions tests/generate-contents-madr.expected
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
adr init docs madr
docs/0001-record-architecture-decisions.md
docs/0000-record-architecture-decisions.md
adr new First Decision
docs/0002-first-decision.md
docs/0001-first-decision.md
adr new Second Decision
docs/0003-second-decision.md
docs/0002-second-decision.md
adr generate toc
# Architecture Decision Records

* [Use Markdown Architectural Decision Records](0001-record-architecture-decisions.md)
* [First Decision](0002-first-decision.md)
* [Second Decision](0003-second-decision.md)
* [Use Markdown Architectural Decision Records](0000-record-architecture-decisions.md)
* [First Decision](0001-first-decision.md)
* [Second Decision](0002-second-decision.md)
52 changes: 26 additions & 26 deletions tests/generate-graph-madr.expected
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
adr init docs madr
docs/0001-record-architecture-decisions.md
docs/0000-record-architecture-decisions.md
adr new An idea that seems good at the time
docs/0002-an-idea-that-seems-good-at-the-time.md
adr new -s 2 A better idea
docs/0003-a-better-idea.md
docs/0001-an-idea-that-seems-good-at-the-time.md
adr new -s 1 A better idea
docs/0002-a-better-idea.md
adr new This will work
docs/0004-this-will-work.md
docs/0003-this-will-work.md
adr new -s 3 The end
docs/0005-the-end.md
docs/0004-the-end.md
# with default extension in links
adr generate graph
digraph {
node [shape=plaintext];
_1 [label="Use Markdown Architectural Decision Records"; URL="0001-record-architecture-decisions.html"]
_2 [label="An idea that seems good at the time"; URL="0002-an-idea-that-seems-good-at-the-time.html"]
_0 [label="Use Markdown Architectural Decision Records"; URL="0000-record-architecture-decisions.html"]
_1 [label="An idea that seems good at the time"; URL="0001-an-idea-that-seems-good-at-the-time.html"]
_0 -> _1 [style="dotted"];
_1 -> _2 [label="Superceded by"]
_2 [label="A better idea"; URL="0002-a-better-idea.html"]
_1 -> _2 [style="dotted"];
_2 -> _3 [label="Superceded by"]
_3 [label="A better idea"; URL="0003-a-better-idea.html"]
_2 -> _1 [label="Supercedes"]
_3 [label="This will work"; URL="0003-this-will-work.html"]
_2 -> _3 [style="dotted"];
_3 -> _2 [label="Supercedes"]
_3 -> _5 [label="Superceded by"]
_4 [label="This will work"; URL="0004-this-will-work.html"]
_3 -> _4 [label="Superceded by"]
_4 [label="The end"; URL="0004-the-end.html"]
_3 -> _4 [style="dotted"];
_5 [label="The end"; URL="0005-the-end.html"]
_4 -> _5 [style="dotted"];
_5 -> _3 [label="Supercedes"]
_4 -> _3 [label="Supercedes"]
}
# with specified extension in links
adr generate graph -e .xxx
digraph {
node [shape=plaintext];
_1 [label="Use Markdown Architectural Decision Records"; URL="0001-record-architecture-decisions.xxx"]
_2 [label="An idea that seems good at the time"; URL="0002-an-idea-that-seems-good-at-the-time.xxx"]
_0 [label="Use Markdown Architectural Decision Records"; URL="0000-record-architecture-decisions.xxx"]
_1 [label="An idea that seems good at the time"; URL="0001-an-idea-that-seems-good-at-the-time.xxx"]
_0 -> _1 [style="dotted"];
_1 -> _2 [label="Superceded by"]
_2 [label="A better idea"; URL="0002-a-better-idea.xxx"]
_1 -> _2 [style="dotted"];
_2 -> _3 [label="Superceded by"]
_3 [label="A better idea"; URL="0003-a-better-idea.xxx"]
_2 -> _1 [label="Supercedes"]
_3 [label="This will work"; URL="0003-this-will-work.xxx"]
_2 -> _3 [style="dotted"];
_3 -> _2 [label="Supercedes"]
_3 -> _5 [label="Superceded by"]
_4 [label="This will work"; URL="0004-this-will-work.xxx"]
_3 -> _4 [label="Superceded by"]
_4 [label="The end"; URL="0004-the-end.xxx"]
_3 -> _4 [style="dotted"];
_5 [label="The end"; URL="0005-the-end.xxx"]
_4 -> _5 [style="dotted"];
_5 -> _3 [label="Supercedes"]
_4 -> _3 [label="Supercedes"]
}
2 changes: 1 addition & 1 deletion tests/generate-graph-madr.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
adr init docs madr
adr new An idea that seems good at the time
adr new -s 2 A better idea
adr new -s 1 A better idea
adr new This will work
adr new -s 3 The end
# with default extension in links
Expand Down
12 changes: 6 additions & 6 deletions tests/init-repository-madr.expected
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
adr init docs madr
docs/0001-record-architecture-decisions.md
docs/0000-record-architecture-decisions.md
ls docs
0001-record-architecture-decisions.md
cat docs/0001-record-architecture-decisions.md
0000-record-architecture-decisions.md
cat docs/0000-record-architecture-decisions.md
# Use Markdown Architectural Decision Records

## Context and Problem Statement
Expand All @@ -12,19 +12,19 @@ Which format and structure should these records follow?

## Considered Options

* [MADR](https://adr.github.io/madr/) 2.0.3 - The Markdown Architectural Decision Records
* [MADR](https://adr.github.io/madr/) 2.1.0 - The Markdown Architectural Decision Records
* [Michael Nygard's template](http://thinkrelevance.com/blog/2011/11/15/documenting-architecture-decisions) - The first incarnation of the term "ADR"
* [Sustainable Architectural Decisions](https://www.infoq.com/articles/sustainable-architectural-design-decisions) - The Y-Statements
* Other templates listed at <https://github.com/joelparkerhenderson/architecture_decision_record>
* Formless - No conventions for file format and structure

## Decision Outcome

Chosen option: "MADR 2.0.3", because
Chosen option: "MADR 2.1.0", because
* Implicit assumptions should be made explicit.
Design documentation is important to enable people understanding the decisions later on.
See also [A rational design process: How and why to fake it](https://doi.org/10.1109/TSE.1986.6312940).
* The MADR format is lean and fits our development style.
* The MADR structure is comprehensible and facilitates usage & maintenance.
* The MADR project is vivid.
* Version 2.0.3 is the latest one available when starting to document ADRs.
* Version 2.1.0 is the latest one available when starting to document ADRs.
2 changes: 1 addition & 1 deletion tests/init-repository-madr.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
adr init docs madr
ls docs
cat docs/0001-record-architecture-decisions.md
cat docs/0000-record-architecture-decisions.md
26 changes: 13 additions & 13 deletions tests/linking-madr.expected
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
adr init docs madr
docs/0001-record-architecture-decisions.md
docs/0000-record-architecture-decisions.md
adr new First Record
docs/0002-first-record.md
docs/0001-first-record.md
adr new Second Record
docs/0003-second-record.md
docs/0002-second-record.md
adr new Third Record
docs/0004-third-record.md
adr link 4 Amends 2 "Amended by"
adr link 4 Clarifies 3 "Clarified by"
tail -5 docs/0002-first-record.md
docs/0003-third-record.md
adr link 3 Amends 1 "Amended by"
adr link 3 Clarifies 2 "Clarified by"
tail -5 docs/0001-first-record.md
## Links <!-- optional -->

* [Link type] [Link to ADR] <!-- example: Refined by [ADR-0005](0005-example.md) -->
* … <!-- numbers of links can vary -->
* Amended by [Third Record](0004-third-record.md)
tail -5 docs/0003-second-record.md
* Amended by [Third Record](0003-third-record.md)
tail -5 docs/0002-second-record.md
## Links <!-- optional -->

* [Link type] [Link to ADR] <!-- example: Refined by [ADR-0005](0005-example.md) -->
* … <!-- numbers of links can vary -->
* Clarified by [Third Record](0004-third-record.md)
tail -6 docs/0004-third-record.md
* Clarified by [Third Record](0003-third-record.md)
tail -6 docs/0003-third-record.md
## Links <!-- optional -->

* [Link type] [Link to ADR] <!-- example: Refined by [ADR-0005](0005-example.md) -->
* … <!-- numbers of links can vary -->
* Amends [First Record](0002-first-record.md)
* Clarifies [Second Record](0003-second-record.md)
* Amends [First Record](0001-first-record.md)
* Clarifies [Second Record](0002-second-record.md)
Loading

0 comments on commit c1ffa52

Please sign in to comment.