Skip to content

feat: dont underscore numbers when formatting module names #710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/html/usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ thread_local! {
}

lazy_static! {
static ref IDENTIFIER_RE: Regex = Regex::new(r"[^a-zA-Z$_]").unwrap();
static ref IDENTIFIER_RE: Regex =
Regex::new(r"^[0-9]|[^a-zA-Z0-9$_]").unwrap();
}

fn render_css_for_usage(name: &str) -> String {
Expand Down
4 changes: 2 additions & 2 deletions tests/snapshots/html_test__html_doc_files_multiple-66.snap
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ Variables</h2></div><div class="namespaceSection"><div id="namespace_default" cl
</section>
</main><div class="toc">
<div><div class="usageContent">
<h3>Usage</h3><div class="markdown"><pre class="highlight"><code class="language-typescript">import * as bar from &quot;foo&quot;;
</code><button class="context_button" data-copy="import * as bar from &quot;foo&quot;;
<h3>Usage</h3><div class="markdown"><pre class="highlight"><code class="language-typescript">import * as bar123 from &quot;foo&quot;;
</code><button class="context_button" data-copy="import * as bar123 from &quot;foo&quot;;
"><svg class="copy" width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="2" y="2" width="7" height="7" fill="none"/>
<rect x="6" y="6" width="7" height="7" fill="none"/>
Expand Down
4 changes: 2 additions & 2 deletions tests/snapshots/html_test__html_doc_files_multiple-67.snap
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ Type</h2></div><div class="space-y-8"><div class=" docEntry" id="variable_defaul
</article></main>
<div class="toc">
<div><div class="usageContent">
<h3>Usage</h3><div class="markdown"><pre class="highlight"><code class="language-typescript">import bar from &quot;foo&quot;;
</code><button class="context_button" data-copy="import bar from &quot;foo&quot;;
<h3>Usage</h3><div class="markdown"><pre class="highlight"><code class="language-typescript">import bar123 from &quot;foo&quot;;
</code><button class="context_button" data-copy="import bar123 from &quot;foo&quot;;
"><svg class="copy" width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="2" y="2" width="7" height="7" fill="none"/>
<rect x="6" y="6" width="7" height="7" fill="none"/>
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/html_test__symbol_group.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8641,7 +8641,7 @@ expression: files
"usages": [
{
"name": "",
"content": "<div class=\"markdown\"><pre class=\"highlight\"><code class=\"language-typescript\">import bar from &quot;foo&quot;;\n</code><button class=\"context_button\" data-copy=\"import bar from &quot;foo&quot;;\n\"><svg class=\"copy\" width=\"15\" height=\"15\" viewBox=\"0 0 15 15\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<rect x=\"2\" y=\"2\" width=\"7\" height=\"7\" fill=\"none\"/>\n<rect x=\"6\" y=\"6\" width=\"7\" height=\"7\" fill=\"none\"/>\n<path d=\"M1.55566 2.7C1.55566 2.03726 2.09292 1.5 2.75566 1.5H8.75566C9.41841 1.5 9.95566 2.03726 9.95566 2.7V5.1H12.3557C13.0184 5.1 13.5557 5.63726 13.5557 6.3V12.3C13.5557 12.9627 13.0184 13.5 12.3557 13.5H6.35566C5.69292 13.5 5.15566 12.9627 5.15566 12.3V9.9H2.75566C2.09292 9.9 1.55566 9.36274 1.55566 8.7V2.7ZM6.35566 9.9V12.3H12.3557V6.3H9.95566V8.7C9.95566 9.36274 9.41841 9.9 8.75566 9.9H6.35566ZM8.75566 8.7V2.7H2.75566V8.7H8.75566Z\" fill=\"#232323\"/>\n</svg>\n<svg class=\"check\" width=\"15\" height=\"15\" viewBox=\"0 0 24 24\" stroke-width=\"2\" stroke=\"#232323\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n<path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\n<path d=\"M5 12l5 5l10 -10\" />\n</svg>\n</button><code></code></pre>\n</div>",
"content": "<div class=\"markdown\"><pre class=\"highlight\"><code class=\"language-typescript\">import bar123 from &quot;foo&quot;;\n</code><button class=\"context_button\" data-copy=\"import bar123 from &quot;foo&quot;;\n\"><svg class=\"copy\" width=\"15\" height=\"15\" viewBox=\"0 0 15 15\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<rect x=\"2\" y=\"2\" width=\"7\" height=\"7\" fill=\"none\"/>\n<rect x=\"6\" y=\"6\" width=\"7\" height=\"7\" fill=\"none\"/>\n<path d=\"M1.55566 2.7C1.55566 2.03726 2.09292 1.5 2.75566 1.5H8.75566C9.41841 1.5 9.95566 2.03726 9.95566 2.7V5.1H12.3557C13.0184 5.1 13.5557 5.63726 13.5557 6.3V12.3C13.5557 12.9627 13.0184 13.5 12.3557 13.5H6.35566C5.69292 13.5 5.15566 12.9627 5.15566 12.3V9.9H2.75566C2.09292 9.9 1.55566 9.36274 1.55566 8.7V2.7ZM6.35566 9.9V12.3H12.3557V6.3H9.95566V8.7C9.95566 9.36274 9.41841 9.9 8.75566 9.9H6.35566ZM8.75566 8.7V2.7H2.75566V8.7H8.75566Z\" fill=\"#232323\"/>\n</svg>\n<svg class=\"check\" width=\"15\" height=\"15\" viewBox=\"0 0 24 24\" stroke-width=\"2\" stroke=\"#232323\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\" xmlns=\"http://www.w3.org/2000/svg\">\n<path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\n<path d=\"M5 12l5 5l10 -10\" />\n</svg>\n</button><code></code></pre>\n</div>",
"icon": null,
"additional_css": ""
}
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata/multiple/b.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @module bar
* @module bar123
*/

export function x(_n = 0) {}
Expand Down
Loading