Skip to content
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

docs(regexp): update module example to get full jsr score #4796

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions regexp/escape.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

/**
* This module contains functions to escape strings for use in regular expressions.
* @module
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does an example make sense here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can copy over the example from the docs of only exported function but it might depend on where this data is rendered on JSR? I see that only mod.ts is rendered on the main page

Copy link
Member Author

@satyarohith satyarohith May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it doesn't make sense to mark escape.ts as an entrypoint considering that there is only one function exported and it's also re-exported from mod.ts

I added an example anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, true. Because std/regexp currently only has one API, setting regexp.ts as entrypoint doesn't make much sense..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kt3k I can open a separate PR to remove it if there is no versioning issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll discuss this with Asher tomorrow. Leave it as is for now (Probably maintainers will handle this if necessary). For now I created an issue #4802

*/

// // For future forward-compatibility with regexp `v` flag, reservedCharMap is
// // autogenerated from the ClassSetReservedDoublePunctuator,
// // ClassSetSyntaxCharacter, and ClassSetReservedPunctuator categories in the
Expand Down
12 changes: 12 additions & 0 deletions regexp/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
* such as escaping text for interpolation into a regexp.
*
* @module
*
* @example
* ```ts
* import { escape } from "@std/regexp";
* import { assertEquals, assertMatch, assertNotMatch } from "@std/assert";
*
* const re = new RegExp(`^${escape(".")}$`, "u");
*
* assertEquals("^\\.$", re.source);
* assertMatch(".", re);
* assertNotMatch("a", re);
* ```
*/

export * from "./escape.ts";