File tree Expand file tree Collapse file tree 3 files changed +54
-3
lines changed Expand file tree Collapse file tree 3 files changed +54
-3
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ architecture notes. It should be structured like that:
34
34
{body}
35
35
```
36
36
37
- [See in context](./src/jsarch.js#L150-L160 )
37
+ [See in context](./src/jsarch.js#L153-L163 )
38
38
39
39
40
40
@@ -51,7 +51,7 @@ A sample tree structure could be:
51
51
- 2
52
52
- 3
53
53
54
- [See in context](./src/jsarch.js#L228-L241 )
54
+ [See in context](./src/jsarch.js#L231-L244 )
55
55
56
56
57
57
Original file line number Diff line number Diff line change @@ -107,7 +107,10 @@ function jsArch({
107
107
content + eol + eol +
108
108
titleLevel + architectureNote . num . split ( '.' ) . map ( ( ) => '#' ) . join ( '' ) +
109
109
' ' + architectureNote . title + eol + eol +
110
- architectureNote . content + eol + eol +
110
+ architectureNote . content . replace (
111
+ new RegExp ( '([\r\n]+)[ \t]{' + architectureNote . loc . indent + '}' , 'g' ) ,
112
+ '$1'
113
+ ) + eol + eol +
111
114
'[See in context](' +
112
115
base + '/' + path . relative ( cwd , architectureNote . filePath ) +
113
116
'#L' + architectureNote . loc . start . line + '-L' + architectureNote . loc . end . line +
Original file line number Diff line number Diff line change @@ -104,6 +104,54 @@ Some content !
104
104
105
105
[See in context](./blob/master/kikoo.js#L3-L6)
106
106
107
+ `
108
+ ) ;
109
+ } )
110
+ ) ;
111
+ } ) ;
112
+
113
+ it . only ( 'with some indented architecture notes in a file' , ( ) => {
114
+ initJSArch ( $ ) ;
115
+
116
+ globStub . returns ( Promise . resolve ( [
117
+ '/home/me/project/kikoo.js' ,
118
+ ] ) ) ;
119
+
120
+ readFileAsyncStub . returns ( Promise . resolve ( `
121
+
122
+ /* Architecture Note #1: Title
123
+
124
+ Some content !
125
+ Nice!
126
+ */
127
+
128
+ console.log('test');
129
+
130
+ ` ) ) ;
131
+
132
+ return $ . run ( [ 'jsArch' ] ) . then ( ( { jsArch } ) =>
133
+ jsArch ( {
134
+ patterns : [ '**/*.js' ] ,
135
+ base : './blob/master' ,
136
+ cwd : '/home/me/project' ,
137
+ } )
138
+ . then ( ( content ) => {
139
+ assert . deepEqual ( readFileAsyncStub . args , [ [
140
+ '/home/me/project/kikoo.js' ,
141
+ 'utf-8' ,
142
+ ] ] ) ;
143
+ assert . equal ( content ,
144
+ `${ JSARCH_PREFIX } # Architecture Notes
145
+
146
+
147
+
148
+ ## Title
149
+
150
+ Some content !
151
+ Nice!
152
+
153
+ [See in context](./blob/master/kikoo.js#L3-L7)
154
+
107
155
`
108
156
) ;
109
157
} )
You can’t perform that action at this time.
0 commit comments