Skip to content

Commit 376e89a

Browse files
committed
Filter out comments from h1s
1 parent 5b4c557 commit 376e89a

File tree

5 files changed

+64
-35
lines changed

5 files changed

+64
-35
lines changed

benchmarks/gradient-autoview.nu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ seq 0 $height | par-each {|| # create these in parallel
1010
let row_data = (seq 0 $width | each { |col|
1111
let fgcolor = 2 + 2 * $col
1212
if $fgcolor > $stamp_start and $fgcolor < $stamp_end {
13-
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
13+
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi reset)"
1414
} else {
15-
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
15+
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi reset)"
1616
}
1717
} | str join)
1818
print -n $"($row_data)" | table

benchmarks/gradient.nu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ for line in 0..$height {
2626
let fgcolor = 2 + 2 * $col
2727

2828
if $fgcolor > 200 and $fgcolor < 210 {
29-
$row_data += $"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
29+
$row_data += $"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi reset)"
3030
} else {
3131
let fg = $fgcolor mod 256
32-
$row_data += $"(ansi -e '48;2;0;0;')($fg)m (ansi -e '0m')"
32+
$row_data += $"(ansi -e '48;2;0;0;')($fg)m (ansi reset)"
3333
}
3434
}
3535

3636
print $row_data
37-
}
37+
}

benchmarks/gradient_benchmark.nu

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ if ($is_release | str downcase | str trim) == "y" {
1717
let row_data = (seq 0 $width | each { |col|
1818
let fgcolor = (iter_inc 2 2 $col)
1919
if $fgcolor > 200 and $fgcolor < 210 {
20-
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
20+
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi reset)"
2121
} else {
22-
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
22+
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi reset)"
2323
}
2424
} | str join)
2525
$"($row_data)(char newline)"
@@ -37,9 +37,9 @@ if ($is_release | str downcase | str trim) == "y" {
3737
let row_data = (seq 0 $width | each { |col|
3838
let fgcolor = (iter_inc 2 2 $col)
3939
if $fgcolor > 200 and $fgcolor < 210 {
40-
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
40+
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi reset)"
4141
} else {
42-
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
42+
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi reset)"
4343
}
4444
} | str join)
4545
$"($row_data)(char cr)"
@@ -56,23 +56,23 @@ if ($is_release | str downcase | str trim) == "y" {
5656
let row_data = (seq 0 $width | each { |col|
5757
let fgcolor = (iter_inc 2 2 $col)
5858
if $fgcolor > 200 and $fgcolor < 210 {
59-
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
59+
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi reset)"
6060
} else {
61-
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
61+
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi reset)"
6262
}
6363
} | str join)
6464
$"($row_data)(char cr)"
6565
} | str join
6666
}} | math avg)
6767

6868
print $"running test 3 at (date now | format date '%Y-%m-%d %H:%M:%S.%3f')"
69-
# 3. Precompute (ansi -e '48;2;0;0;') and (ansi -e '0m') -- seems to be slower
69+
# 3. Precompute (ansi -e '48;2;0;0;') and (ansi reset) -- seems to be slower
7070
let 3 = (seq 1 10 | each { timeit {
7171
let height = 40
7272
let width = 160
7373
let stamp = 'Nu'
7474
let ansi1 = (ansi -e '48;2;0;0;')
75-
let ansi2 = (ansi -e '0m')
75+
let ansi2 = (ansi reset)
7676
seq 0 $height | each { |row|
7777
let row_data = (seq 0 $width | each { |col|
7878
let fgcolor = (iter_inc 2 2 $col)
@@ -96,9 +96,9 @@ if ($is_release | str downcase | str trim) == "y" {
9696
let row_data = (seq 0 $width | each { |col|
9797
let fgcolor = 2 + 2 * $col
9898
if $fgcolor > 200 and $fgcolor < 210 {
99-
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
99+
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi reset)"
100100
} else {
101-
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
101+
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi reset)"
102102
}
103103
} | str join)
104104
$"($row_data)(char cr)"
@@ -115,9 +115,9 @@ if ($is_release | str downcase | str trim) == "y" {
115115
let row_data = (seq 0 $width | each { |col|
116116
let fgcolor = 2 + 2 * $col
117117
if $fgcolor > 200 and $fgcolor < 210 {
118-
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
118+
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi reset)"
119119
} else {
120-
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
120+
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi reset)"
121121
}
122122
} | str join)
123123
$"($row_data)(char cr)"
@@ -134,9 +134,9 @@ if ($is_release | str downcase | str trim) == "y" {
134134
let row_data = (seq 0 $width | each { |col|
135135
let fgcolor = 2 + 2 * $col
136136
if $fgcolor > 200 and $fgcolor < 210 {
137-
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
137+
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi reset)"
138138
} else {
139-
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
139+
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi reset)"
140140
}
141141
} | str join)
142142
$"($row_data)(char cr)"

benchmarks/gradient_benchmark_no_check.nu

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ if ($is_release | str downcase | str trim) == "y" {
1919
let row_data = (seq 0 $width | each { |col|
2020
let fgcolor = (iter_inc 2 2 $col)
2121
if $fgcolor > 200 and $fgcolor < 210 {
22-
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
22+
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi reset)"
2323
} else {
24-
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
24+
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi reset)"
2525
}
2626
} | str join)
2727
$"($row_data)(char newline)"
@@ -39,9 +39,9 @@ if ($is_release | str downcase | str trim) == "y" {
3939
let row_data = (seq 0 $width | each { |col|
4040
let fgcolor = (iter_inc 2 2 $col)
4141
if $fgcolor > 200 and $fgcolor < 210 {
42-
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
42+
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi reset)"
4343
} else {
44-
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
44+
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi reset)"
4545
}
4646
} | str join)
4747
$"($row_data)(char cr)"
@@ -58,23 +58,23 @@ if ($is_release | str downcase | str trim) == "y" {
5858
let row_data = (seq 0 $width | each { |col|
5959
let fgcolor = (iter_inc 2 2 $col)
6060
if $fgcolor > 200 and $fgcolor < 210 {
61-
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
61+
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi reset)"
6262
} else {
63-
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
63+
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi reset)"
6464
}
6565
} | str join)
6666
$"($row_data)(char cr)"
6767
} | str join
6868
} | math avg)
6969

7070
print $"running test 3 at (date now | format date '%Y-%m-%d %H:%M:%S.%3f')"
71-
# 3. Precompute (ansi -e '48;2;0;0;') and (ansi -e '0m') -- seems to be slower
71+
# 3. Precompute (ansi -e '48;2;0;0;') and (ansi reset) -- seems to be slower
7272
let 3 = (seq 10 | timeit {
7373
let height = 40
7474
let width = 160
7575
let stamp = 'Nu'
7676
let ansi1 = (ansi -e '48;2;0;0;')
77-
let ansi2 = (ansi -e '0m')
77+
let ansi2 = (ansi reset)
7878
seq 0 $height | each { |row|
7979
let row_data = (seq 0 $width | each { |col|
8080
let fgcolor = (iter_inc 2 2 $col)
@@ -98,9 +98,9 @@ if ($is_release | str downcase | str trim) == "y" {
9898
let row_data = (seq 0 $width | each { |col|
9999
let fgcolor = 2 + 2 * $col
100100
if $fgcolor > 200 and $fgcolor < 210 {
101-
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
101+
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi reset)"
102102
} else {
103-
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
103+
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi reset)"
104104
}
105105
} | str join)
106106
$"($row_data)(char cr)"
@@ -117,9 +117,9 @@ if ($is_release | str downcase | str trim) == "y" {
117117
let row_data = (seq 0 $width | each { |col|
118118
let fgcolor = 2 + 2 * $col
119119
if $fgcolor > 200 and $fgcolor < 210 {
120-
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
120+
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi reset)"
121121
} else {
122-
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
122+
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi reset)"
123123
}
124124
} | str join)
125125
$"($row_data)(char cr)"
@@ -136,9 +136,9 @@ if ($is_release | str downcase | str trim) == "y" {
136136
let row_data = (seq 0 $width | each { |col|
137137
let fgcolor = 2 + 2 * $col
138138
if $fgcolor > 200 and $fgcolor < 210 {
139-
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
139+
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi reset)"
140140
} else {
141-
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi -e '0m')"
141+
$"(ansi -e '48;2;0;0;')($fgcolor)m (ansi reset)"
142142
}
143143
} | str join)
144144
$"($row_data)(char cr)"

make_release/release-note/notes.nu

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ const toc = '[[toc](#table-of-contents)]'
4848

4949
# Generate and write the table of contents to a release notes file
5050
export def write-toc [file: path] {
51+
let known_h1s = [
52+
"# Highlights and themes of this release",
53+
"# Changes",
54+
"# Notes for plugin developers",
55+
"# Hall of fame",
56+
"# Full changelog",
57+
]
58+
5159
let lines = open $file | lines | each { str trim -r }
5260

5361
let content_start = 2 + (
@@ -64,12 +72,33 @@ export def write-toc [file: path] {
6472
| wrap line
6573
| insert level {
6674
get line | split chars | take while { $in == '#' } | length
75+
}
76+
| insert nocomment {
77+
if ($in.level == 1) {
78+
let line = $in.line
79+
80+
# Try to use the whitelist first
81+
if ($known_h1s | any {|| $line =~ $in}) {
82+
return true
83+
}
84+
let user = ([Ignore Accept] |
85+
input list $"Is this a code comment or a markdown h1 heading:(char nl)(ansi blue)($line)(ansi reset)(char nl)Choose if we include it in the TOC!")
86+
match $user {
87+
"Accept" => {true}
88+
"Ignore" => {false}
89+
}
90+
91+
} else {
92+
return true
93+
}
6794
}
6895
)
6996

97+
print $data
98+
7099
let table_of_contents = (
71100
$data
72-
| where level in 1..=3
101+
| where level in 1..=3 and nocomment == true
73102
| each {|header|
74103
let indent = '- ' | fill -w ($header.level * 2) -a right
75104

@@ -91,7 +120,7 @@ export def write-toc [file: path] {
91120
)
92121

93122
let content = $data | each {
94-
if $in.level in 1..=3 and not ($in.line ends-with $toc) {
123+
if $in.level in 1..=3 and not ($in.line ends-with $toc) and $in.nocomment {
95124
$'($in.line) ($toc)'
96125
} else {
97126
$in.line

0 commit comments

Comments
 (0)