Skip to content

Commit

Permalink
fix(summary): set summary as a markdown list
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinedmc committed Oct 17, 2021
1 parent 4902fea commit 390876a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 34 deletions.
33 changes: 14 additions & 19 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,17 @@
[//]: # ( )
# Architecture Notes

Summary
## Summary

[1 jsArch service](#1-jsarch-service)
1. [jsArch service](#1-jsarch-service)
1. [Extraction](#11-extraction)
2. [Ordering](#12-ordering)
3. [Title level](#13-title-level)
4. [Base](#14-base)
2. [CLI](#2-cli)

[1.1 Extraction](#11-extraction)

[1.2 Ordering](#12-ordering)

[1.3 Title level](#13-title-level)

[1.4 Base](#14-base)

[2 CLI](#2-cli)


## 1 jsArch service
## 1. jsArch service

JSArch is basically a service that exposes a function allowing
to extract and output architecture notes from the code.
Expand All @@ -36,7 +31,7 @@ This service needs some other services. To be able to mock and



### 1.1 Extraction
### 1.1. Extraction

We use AST parsing and visiting to retrieve well formed
architecture notes. It should be structured like that:
Expand All @@ -47,11 +42,11 @@ architecture notes. It should be structured like that:
{body}
```
[See in context](./src/jsarch.js#L254-L264)
[See in context](./src/jsarch.js#L264-L274)
### 1.2 Ordering
### 1.2. Ordering
To order architecture notes in a meaningful way we
use title hierarchy like we used too at school with
Expand All @@ -68,7 +63,7 @@ A sample tree structure could be:
### 1.3 Title level
### 1.3. Title level
By default, titles will be added like if the architecture
notes were in a single separated file.
Expand All @@ -81,7 +76,7 @@ If you wish to add the architecture notes in a README.md file
### 1.4 Base
### 1.4. Base
By default, links to the architecture notes right in the code
are supposed relative to the README.md file like you would
Expand All @@ -93,7 +88,7 @@ To override it, use the `base` option.
## 2 CLI
## 2. CLI
The JSArch CLI tool basically wraps the jsArch service
to make it usable from the CLI.
Expand Down
22 changes: 16 additions & 6 deletions src/jsarch.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,22 @@ async function initJSArch({ CONFIG, EOL, glob, fs, parser, log = noop }) {
architectureNote.num.replace('.', '') +
'-' +
architectureNote.title.toLowerCase().replace(/ /g, '-');

const titleNums = architectureNote.num.split('.');

let tabulation = '';
for (let i = 0; i < titleNums.length; i++) {
if (i > 0) {
tabulation += ' ';
}
}

return (
summary +
eol +
eol +
'[' +
architectureNote.num +
' ' +
tabulation +
titleNums[titleNums.length - 1] +
'. [' +
architectureNote.title +
']' +
'(#' +
Expand Down Expand Up @@ -184,7 +193,7 @@ async function initJSArch({ CONFIG, EOL, glob, fs, parser, log = noop }) {
.join('') +
' ' +
architectureNote.num +
' ' +
'. ' +
architectureNote.title +
eol +
eol +
Expand Down Expand Up @@ -215,7 +224,8 @@ async function initJSArch({ CONFIG, EOL, glob, fs, parser, log = noop }) {
' Architecture Notes' +
eol +
eol +
'Summary' +
'## Summary' +
eol +
summary +
eol +
content
Expand Down
18 changes: 9 additions & 9 deletions src/jsarch.mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ console.log('test');
Summary
[1 Title](#1-title)
1. [Title](#1-title)
## 1 Title
Expand Down Expand Up @@ -138,7 +138,7 @@ console.log('test');
Summary
[1 \`$autoload\`](#1-\`$autoload\`)
1. [\`$autoload\`](#1-\`$autoload\`)
## 1 \`$autoload\`
Expand Down Expand Up @@ -195,7 +195,7 @@ console.log('test');
Summary
[1 Title](#1-title)
1. [Title](#1-title)
## 1 Title
Expand Down Expand Up @@ -246,7 +246,7 @@ console.log('test');
Summary
[1 Title](#1-title)
1. [Title](#1-title)
## 1 Title
Expand Down Expand Up @@ -291,7 +291,7 @@ console.log('test');
Summary
[1 Title](#1-title)
1. [Title](#1-title)
## 1 Title
Expand Down Expand Up @@ -361,13 +361,13 @@ Some content !
Summary
[1 Title](#1-title)
1. [Title](#1-title)
[1.1 Title](#11-title)
1. [Title](#11-title)
[1.3 Title](#13-title)
3. [Title](#13-title)
[2 Title](#2-title)
2. [Title](#2-title)
## 1 Title
Expand Down

0 comments on commit 390876a

Please sign in to comment.