npryce / adr-tools

Command-line tools for working with Architecture Decision Records
Other
4.6k stars 584 forks source link

Custom ADR template? #120

Open devinnasar opened 3 years ago

devinnasar commented 3 years ago

Hello,

One thing I'd like to do is synchronize ADRs in git repos with documentation published in Confluence. To that end, I'd like to use this project: https://github.com/kovetskiy/mark, which requires adding special notation to markdown files. I'd like to be able to use a custom ADR template on a per-repo basis. Does adr-tools support this currently/is there a way to accomplish this? Thanks!

imankulov commented 2 years ago

adr-tools support custom templates

The documentation may not be clear, but this example in tests shows how to use them.

You create a file templates/template.md inside a directory with your ADRs. In the template, you can use variables TITLE, STATUS, NUMBER, and DATE (just like this, words in uppercase.) That's it. The next call of adr new will use this template.

gelisam commented 2 years ago

Note that _adr_title currently assumes that the first line of the file has the form # TITLE. Thus, given the template

<!-- Space: <space key> -->
<!-- Title: TITLE -->

## Status

STATUS

## Next section

Running adr new "My Test" will correctly generate an ADR file with the title in the right spot:

EDITOR=cat adr new "My test"
<!-- Space: <space key> -->
<!-- Title: My test -->

## Status

Accepted

## Next section

But the other commands will use the wrong title to refer to the "My Test" ADR:

$ EDITOR=cat adr new "My Test"
<!-- Space: <space key> -->
<!-- Title: My Test -->

## Status

Accepted

## Next section

$ EDITOR=cat adr new -s my-test "My Second Test"
<!-- Space: <space key> -->
<!-- Title: My Second Test -->

## Status

Accepted

Supercedes [-- Space: <space key> -->](0002-my-test.md)

## Next section

$ cat docs/adr/0002-my-test.md
<!-- Space: <space key> -->
<!-- Title: My Test -->

## Status

Superceded by [-- Space: <space key> -->](0003-my-second-test.md)

## Next section

$ adr generate toc
# Architecture Decision Records

* [1. Record architecture decisions](0001-record-architecture-decisions.md)
* [-- Space: <space key> -->](0002-my-test.md)
* [-- Space: <space key> -->](0003-my-second-test.md)