Skip to content

Commit 62001c1

Browse files
aidanfnvCopilot
andauthored
Fix case-insensitive anchor ID collision in markdown help output (#10095)
Fixes #10083 The markdown help output (`slangc -help-style markdown -h`) generates explicit `<a id>` anchor IDs for headings using case-sensitive deduplication, but GitHub's markdown renderer generates heading IDs case-insensitively. This causes the `## Target` category heading and `## target` value section heading to produce non-colliding explicit anchors (`Target` and `target`), while GitHub assigns them colliding auto-IDs (`target` and `target-1`). The auto-ID `target-1` for `## target` then coincides with the explicit anchor for the `### -target` option, so clicking "target" in GitHub's right-side navigation scrolls to the `-target` option instead of the target value list. This fix lowercases anchor ID prefixes in `_getLinkName` so that deduplication matches GitHub's case-insensitive behavior. The explicit anchors now align with GitHub's auto-generated heading IDs, and the right-side navigation links to the correct sections. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 74f1dc8 commit 62001c1

File tree

2 files changed

+34
-31
lines changed

2 files changed

+34
-31
lines changed

docs/command-line-slangc-reference.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ slangc -help-style markdown -h
1212
```
1313
### Quick Links
1414

15-
* [General](#General)
16-
* [Target](#Target)
17-
* [Downstream](#Downstream)
18-
* [Debugging](#Debugging)
19-
* [Repro](#Repro)
20-
* [Experimental](#Experimental)
21-
* [Internal](#Internal)
22-
* [Deprecated](#Deprecated)
15+
* [General](#general)
16+
* [Target](#target)
17+
* [Downstream](#downstream)
18+
* [Debugging](#debugging)
19+
* [Repro](#repro)
20+
* [Experimental](#experimental)
21+
* [Internal](#internal)
22+
* [Deprecated](#deprecated)
2323
* [compiler](#compiler)
2424
* [language](#language)
2525
* [language-version](#language-version)
@@ -33,19 +33,19 @@ slangc -help-style markdown -h
3333
* [debug-level](#debug-level)
3434
* [file-system-type](#file-system-type)
3535
* [source-embed-style](#source-embed-style)
36-
* [target](#target)
36+
* [target](#target-1)
3737
* [stage](#stage)
3838
* [vulkan-shift](#vulkan-shift)
3939
* [capability](#capability)
4040
* [file-extension](#file-extension)
4141
* [help-category](#help-category)
4242

43-
<a id="General"></a>
43+
<a id="general"></a>
4444
## General
4545

4646
General options
4747

48-
<a id="D"></a>
48+
<a id="d"></a>
4949
### -D
5050

5151
**-D&lt;name&gt;\[=&lt;value&gt;\], -D &lt;name&gt;\[=&lt;value&gt;\]**
@@ -108,7 +108,7 @@ Print this message, or help in specified category.
108108
Help formatting style
109109

110110

111-
<a id="I"></a>
111+
<a id="i"></a>
112112
### -I
113113

114114
**-I&lt;path&gt;, -I &lt;path&gt;**
@@ -174,7 +174,7 @@ Set the module name to use when compiling multiple .slang source files into a si
174174

175175
Specify a path where generated output should be written.
176176

177-
If no [-target](#target-1) or [-stage](#stage-1) is specified, one may be inferred from file extension (see [&lt;file-extension&gt;](#file-extension)). If multiple [-target](#target-1) options and a single [-entry](#entry) are present, each [-o](#o) associates with the first [-target](#target-1) to its left. Otherwise, if multiple [-entry](#entry) options are present, each [-o](#o) associates with the first [-entry](#entry) to its left, and with the [-target](#target-1) that matches the one inferred from &lt;path&gt;.
177+
If no [-target](#target-2) or [-stage](#stage-1) is specified, one may be inferred from file extension (see [&lt;file-extension&gt;](#file-extension)). If multiple [-target](#target-2) options and a single [-entry](#entry) are present, each [-o](#o) associates with the first [-target](#target-2) to its left. Otherwise, if multiple [-entry](#entry) options are present, each [-o](#o) associates with the first [-entry](#entry) to its left, and with the [-target](#target-2) that matches the one inferred from &lt;path&gt;.
178178

179179

180180
<a id="profile"></a>
@@ -196,7 +196,7 @@ Additional profiles that include [-stage](#stage-1) information:
196196

197197
See [-capability](#capability-1) for information on [&lt;capability&gt;](#capability)
198198

199-
When multiple [-target](#target-1) options are present, each [-profile](#profile) associates with the first [-target](#target-1) to its left.
199+
When multiple [-target](#target-2) options are present, each [-profile](#profile) associates with the first [-target](#target-2) to its left.
200200

201201

202202
<a id="stage-1"></a>
@@ -211,10 +211,10 @@ When multiple [-entry](#entry) options are present, each [-stage](#stage-1) asso
211211
May be omitted if entry-point function has a \[shader(...)\] attribute; otherwise required for each [-entry](#entry) option.
212212

213213

214-
<a id="target-1"></a>
214+
<a id="target-2"></a>
215215
### -target
216216

217-
**-target &lt;[target](#target)&gt;**
217+
**-target &lt;[target](#target-1)&gt;**
218218

219219
Specifies the format in which code should be generated.
220220

@@ -254,15 +254,15 @@ all - Treat all warnings as errors.
254254
Disable specific warning ids.
255255

256256

257-
<a id="W"></a>
257+
<a id="w"></a>
258258
### -W
259259

260260
**-W&lt;id&gt;**
261261

262262
Enable a warning with the specified id.
263263

264264

265-
<a id="Wno"></a>
265+
<a id="wno"></a>
266266
### -Wno-
267267

268268
**-Wno-&lt;id&gt;**
@@ -377,7 +377,7 @@ Pack bitfields according to MSVC rules (msb first, new field when underlying typ
377377

378378

379379

380-
<a id="Target"></a>
380+
<a id="target"></a>
381381
## Target
382382

383383
Target code generation options
@@ -461,7 +461,7 @@ Sets how the `#line` directives should be produced. Available options are:
461461
If not specified, default behavior is to use C-style `#line` directives for HLSL and C/C++ output, and traditional GLSL-style `#line` directives for GLSL output.
462462

463463

464-
<a id="O"></a>
464+
<a id="o-1"></a>
465465
### -O
466466

467467
**-O&lt;[optimization-level](#optimization-level)&gt;**
@@ -615,7 +615,7 @@ Sets a comma-separates list of architecture-specific features for the LLVM targe
615615

616616

617617

618-
<a id="Downstream"></a>
618+
<a id="downstream"></a>
619619
## Downstream
620620

621621
Downstream compiler options
@@ -638,12 +638,12 @@ Specify path to a downstream [&lt;compiler&gt;](#compiler) executable or library
638638
Set a default compiler for the given language. See [-lang](#lang) for the list of languages.
639639

640640

641-
<a id="X"></a>
641+
<a id="x"></a>
642642
### -X
643643

644644
**-X&lt;[compiler](#compiler)&gt; &lt;option&gt; -X&lt;[compiler](#compiler)&gt;... &lt;options&gt; -X.**
645645

646-
Pass arguments to downstream [&lt;compiler&gt;](#compiler). Just [-X&lt;compiler&gt;](#X) passes just the next argument to the downstream compiler. [-X&lt;compiler&gt;](#X)... options [-X](#X). will pass *all* of the options inbetween the opening [-X](#X) and [-X](#X). to the downstream compiler.
646+
Pass arguments to downstream [&lt;compiler&gt;](#compiler). Just [-X&lt;compiler&gt;](#x) passes just the next argument to the downstream compiler. [-X&lt;compiler&gt;](#x)... options [-X](#x). will pass *all* of the options inbetween the opening [-X](#x) and [-X](#x). to the downstream compiler.
647647

648648

649649
<a id="pass-through"></a>
@@ -657,7 +657,7 @@ These are intended for debugging/testing purposes, when you want to be able to s
657657

658658

659659

660-
<a id="Debugging"></a>
660+
<a id="debugging"></a>
661661
## Debugging
662662

663663
Compiler debugging/instrumentation options
@@ -690,7 +690,7 @@ Dump the IR after every pass for debugging.
690690
Dump the IDs with [-dump-ir](#dump-ir) (debug builds only)
691691

692692

693-
<a id="E"></a>
693+
<a id="e"></a>
694694
### -E, -output-preprocessor
695695
Output the preprocessing result and exit.
696696

@@ -767,7 +767,7 @@ Print the minimum and maximum module versions this compiler supports
767767

768768

769769

770-
<a id="Repro"></a>
770+
<a id="repro"></a>
771771
## Repro
772772

773773
Slang repro system related
@@ -827,7 +827,7 @@ There are two *special* directories:
827827

828828

829829

830-
<a id="Experimental"></a>
830+
<a id="experimental"></a>
831831
## Experimental
832832

833833
Experimental options (use at your own risk)
@@ -909,7 +909,7 @@ Control colored diagnostic output (auto uses color if stderr is a tty)
909909

910910

911911

912-
<a id="Internal"></a>
912+
<a id="internal"></a>
913913
## Internal
914914

915915
Internal-use options (use at your own risk)
@@ -1002,7 +1002,7 @@ Generate code for all entry points in a single output (library mode).
10021002

10031003

10041004

1005-
<a id="Deprecated"></a>
1005+
<a id="deprecated"></a>
10061006
## Deprecated
10071007

10081008
Deprecated options (allowed but ignored; may be removed in future)
@@ -1162,7 +1162,7 @@ Source Embed Style
11621162
* `u32` : Embed as uint32_t.
11631163
* `u64` : Embed as uint64_t.
11641164

1165-
<a id="target"></a>
1165+
<a id="target-1"></a>
11661166
## target
11671167

11681168
Target

source/core/slang-command-options-writer.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,10 @@ UnownedStringSlice MarkdownCommandOptionsWriter::_getLinkName(const NameKey& key
440440
}
441441

442442
StringBuilder buf;
443-
buf << prefix;
443+
for (char c : prefix)
444+
{
445+
buf.append(CharUtil::toLower(c));
446+
}
444447

445448
const auto bufLen = buf.getLength();
446449

0 commit comments

Comments
 (0)