File tree 4 files changed +21
-8
lines changed
4 files changed +21
-8
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' rankify-contracts ' : patch
3
+ ---
4
+
5
+ doc generation template improvements
Original file line number Diff line number Diff line change 1
- {{ h 2 }} {{ visibility }} {{ toLowerCase type }} {{ name }}
2
1
3
2
{{ #if (isVisible visibility )}}
4
3
{{ h 2 }} {{ name }}
10
9
{{{ signature }}}
11
10
```
12
11
{{ /if }}
12
+ {{ /if }}
13
13
14
14
{{ #if natspec.params }}
15
15
| Input | Type | Description |
36
36
{{ #if natspec.dev }}
37
37
{{{ transformDev (substituteAnchors natspec.dev )}}}
38
38
{{ /if }}
39
+
Original file line number Diff line number Diff line change 1
- ## Description
2
-
3
1
{{{ natspec.notice }}}
4
2
5
- {{{ natspec.dev }}}
3
+ {{{ transformDev ( substituteAnchors natspec.dev ) }}}
6
4
7
- ## Implementation
8
5
9
6
{{ #each items }}
10
7
{{> item }}
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ export function joinLines(text?: string) {
64
64
65
65
export function transformDev ( comment : string ) : string {
66
66
// Split the comment into lines
67
- const lines = comment . split ( '\n' ) ;
67
+ const lines = comment ? .split ( '\n' ) ?? [ ] ;
68
68
69
69
// Initialize variables to store the transformed text
70
70
let transformedText = '' ;
@@ -117,8 +117,18 @@ export const isVisible = (type: string) => {
117
117
118
118
export const substituteAnchors = ( text : string ) => {
119
119
if ( typeof text === 'string' ) {
120
- return text . replace ( / { ( \w + ) } / g, ( match : string , p1 : string ) => {
121
- return `[${ p1 } ](#${ p1 . toLocaleLowerCase ( ) } )` ;
120
+ return text . replace ( / { ( [ ^ } ] + ) } / g, ( match : string , p1 : string ) => {
121
+ // Split the reference into parts
122
+ const parts = p1 . split ( '.' ) ;
123
+ const anchor = parts . length > 1 ? `#${ parts . slice ( 1 ) . join ( '.' ) . toLocaleLowerCase ( ) } ` : '' ;
124
+ const reference = parts [ 0 ] ;
125
+ const displayText = reference . charAt ( 0 ) . toUpperCase ( ) + reference . slice ( 1 ) ;
126
+
127
+ // Handle different depth levels
128
+ const path = reference . startsWith ( '../' ) ? reference : `./${ reference } ` ;
129
+
130
+ return `[${ displayText } ${ anchor } ](../${ path } ${ anchor } )` ;
122
131
} ) ;
123
132
}
133
+ return text ;
124
134
} ;
You can’t perform that action at this time.
0 commit comments