Skip to content

Conversation

@emnul
Copy link
Contributor

@emnul emnul commented Oct 8, 2025

Removes docs directory since we're now maintaining our online docs at OpenZepplin/docs. Updates GUIDELINES and CONTRIBUTING files

Closes #265

Summary by CodeRabbit

  • Documentation

    • Reorganized documentation structure and removed outdated API reference pages
    • Updated contribution guidelines with enhanced links for new contributors
  • Chores

    • Removed documentation build scripts and configuration files
    • Updated pull request template with guidance-oriented references

@emnul emnul requested a review from a team as a code owner October 8, 2025 22:11
Copy link
Contributor

@andrew-fleming andrew-fleming left a comment

Choose a reason for hiding this comment

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

Looks good! We still have the old site that's connected: https://old-docs.openzeppelin.com/contracts-compact/0.0.1/ . I think we should create a docs branch then update the playbook on the old docs repo here like this:

    - url: https://github.com/OpenZeppelin/compact-contracts
      branches:
        - docs-v*
      start_path: docs

so it can fetch the last prerelease (as opposed to reading from HEAD as it is now). WDYT?


Also, I think we can remove the docs tasks in turbo.json. I just left a question and a small suggestion. Lastly, I'd create an issue since it's not a trivial change so we can track it in the project :)

Comment on lines +30 to +33
The online version of the Compact contracts documentation is maintained at [OpenZeppelin/docs](https://github.com/OpenZeppelin/docs).
It should mirror all documentation embedded within the contracts themselves with additional context and usage examples if applicable.
Pull requests in [OpenZeppelin/docs](https://github.com/OpenZeppelin/docs) should be linked to the corresponding pull request in this repo.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sooooooooooooo this adds a ton of friction for contributors. It's a good idea to have some coordination with linking a PR from the docs repo as you mentioned; however, this feels messy. The consequences of centralization :(

I was considering if we could place the docs repo in a submodule or subtree so all changes are, from the contributor's perspective, from the same project. The former is a bit more convenient for the contributor but they need to know how to work with submodules. The latter adds complexity to us but improves dx for the contributor...or keep it as-is. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally agree, I think we can make this easier on contributors by using Git subtrees. I can add some scripts and more info to CONTRIBUTING.md to standardize the workflow.

package.json Outdated
Comment on lines 10 to 12
"scripts": {
"docs": "turbo run docs --filter=docs",
"docs:watch": "turbo run docs:watch --filter=docs",
"compact": "turbo run compact --filter=@openzeppelin-compact/contracts --log-prefix=none",
"build": "turbo run build --filter=!'docs' --log-prefix=none",
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove --filter=!'docs' in build

@coderabbitai
Copy link

coderabbitai bot commented Nov 7, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request deprecates the embedded documentation directory by removing all module documentation pages, API references, Antora configuration, and documentation build scripts. Documentation content is being migrated to an external repository, and references in root-level configuration files are updated accordingly.

Changes

Cohort / File(s) Summary
PR template and contributing guide updates
.github/PULL_REQUEST_TEMPLATE.md, CONTRIBUTING.md, GUIDELINES.md
Updated PR checklist with guidance links to CONTRIBUTING.md#your-first-code-contribution and GUIDELINES.md; fixed bullet point formatting in contributing guide; added documentation guidance about external OpenZeppelin/docs repository
Documentation configuration
docs/antora.yml
Removed Antora site configuration block (contracts-compact module, version 0.0.1, navigation, and asciidoc attributes)
Documentation navigation structure
docs/modules/ROOT/nav.adoc
Removed all navigation entries including Overview, Learn, ZK Circuits 101, Extensibility, Modules, Tokens, and Utils sections with their xref links
API reference pages
docs/modules/ROOT/pages/api/access.adoc, docs/modules/ROOT/pages/api/fungibleToken.adoc, docs/modules/ROOT/pages/api/multitoken.adoc, docs/modules/ROOT/pages/api/nonFungibleToken.adoc, docs/modules/ROOT/pages/api/security.adoc, docs/modules/ROOT/pages/api/utils.adoc
Deleted comprehensive API documentation pages for AccessControl, FungibleToken, MultiToken, NonFungibleToken, Security, and Utils modules
Module documentation pages
docs/modules/ROOT/pages/access.adoc, docs/modules/ROOT/pages/extensibility.adoc, docs/modules/ROOT/pages/fungibleToken.adoc, docs/modules/ROOT/pages/multitoken.adoc, docs/modules/ROOT/pages/nonFungibleToken.adoc, docs/modules/ROOT/pages/security.adoc, docs/modules/ROOT/pages/utils.adoc, docs/modules/ROOT/pages/zkCircuits101.adoc
Removed all module documentation pages describing patterns, usage examples, constraints, and implementation guidance
Documentation index and manifest
docs/modules/ROOT/pages/index.adoc, docs/package.json
Deleted main documentation landing page with setup instructions, examples, and compilation output; deleted docs package manifest
Build scripts
package.json
Removed docs and docs:watch script entries from root package manifest

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

  • Attention areas: Verify that all documentation files targeted for removal are included (compare against docs directory structure to ensure completeness); confirm that script removals in package.json align with the deprecation plan; validate that the updated PR template links and GUIDELINES.md additions correctly point to the new external documentation location.

Poem

🐰 The docs hop away to distant lands,
To live where OpenZeppelin stands,
Our burrows now clear, our path is bright,
Configuration scripts take graceful flight,
A new chapter starts, our branches unite! 📚✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR partially addresses the linked issue #265 requirements: removes docs tasks from package.json scripts and removes the docs directory, but does not create the docs branch or update the playbook on the old docs repo. Complete the remaining tasks from issue #265: create a docs branch, update the playbook on OpenZeppelin/docs.openzeppelin.com to reference the new branch, and create a subtree pointing to OpenZeppelin/docs.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Removes docs directory' directly and accurately summarizes the main change—the removal of the docs directory and related documentation files.
Out of Scope Changes check ✅ Passed Changes to .github/PULL_REQUEST_TEMPLATE.md, CONTRIBUTING.md, and GUIDELINES.md regarding documentation links and guidance are relevant to the docs transition mentioned in PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
GUIDELINES.md (1)

30-32: Add comma for clarity.

Line 31 would read more clearly with a comma before the prepositional phrase.

Apply this diff:

- It should mirror all documentation embedded within the contracts themselves with additional context and usage examples if applicable.
+ It should mirror all documentation embedded within the contracts themselves, with additional context and usage examples if applicable.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fb079ec and f5bc4c7.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (22)
  • .github/PULL_REQUEST_TEMPLATE.md (1 hunks)
  • CONTRIBUTING.md (1 hunks)
  • GUIDELINES.md (1 hunks)
  • docs/antora.yml (0 hunks)
  • docs/modules/ROOT/nav.adoc (0 hunks)
  • docs/modules/ROOT/pages/access.adoc (0 hunks)
  • docs/modules/ROOT/pages/api/access.adoc (0 hunks)
  • docs/modules/ROOT/pages/api/fungibleToken.adoc (0 hunks)
  • docs/modules/ROOT/pages/api/multitoken.adoc (0 hunks)
  • docs/modules/ROOT/pages/api/nonFungibleToken.adoc (0 hunks)
  • docs/modules/ROOT/pages/api/security.adoc (0 hunks)
  • docs/modules/ROOT/pages/api/utils.adoc (0 hunks)
  • docs/modules/ROOT/pages/extensibility.adoc (0 hunks)
  • docs/modules/ROOT/pages/fungibleToken.adoc (0 hunks)
  • docs/modules/ROOT/pages/index.adoc (0 hunks)
  • docs/modules/ROOT/pages/multitoken.adoc (0 hunks)
  • docs/modules/ROOT/pages/nonFungibleToken.adoc (0 hunks)
  • docs/modules/ROOT/pages/security.adoc (0 hunks)
  • docs/modules/ROOT/pages/utils.adoc (0 hunks)
  • docs/modules/ROOT/pages/zkCircuits101.adoc (0 hunks)
  • docs/package.json (0 hunks)
  • package.json (0 hunks)
💤 Files with no reviewable changes (19)
  • docs/modules/ROOT/nav.adoc
  • docs/modules/ROOT/pages/access.adoc
  • docs/modules/ROOT/pages/multitoken.adoc
  • docs/modules/ROOT/pages/api/nonFungibleToken.adoc
  • docs/modules/ROOT/pages/security.adoc
  • docs/modules/ROOT/pages/index.adoc
  • docs/modules/ROOT/pages/api/security.adoc
  • docs/modules/ROOT/pages/utils.adoc
  • docs/antora.yml
  • package.json
  • docs/modules/ROOT/pages/zkCircuits101.adoc
  • docs/modules/ROOT/pages/api/access.adoc
  • docs/package.json
  • docs/modules/ROOT/pages/fungibleToken.adoc
  • docs/modules/ROOT/pages/extensibility.adoc
  • docs/modules/ROOT/pages/nonFungibleToken.adoc
  • docs/modules/ROOT/pages/api/utils.adoc
  • docs/modules/ROOT/pages/api/fungibleToken.adoc
  • docs/modules/ROOT/pages/api/multitoken.adoc
🧰 Additional context used
🪛 LanguageTool
GUIDELINES.md

[uncategorized] ~31-~31: Possible missing comma found.
Context: ...mentation embedded within the contracts themselves with additional context and usage examp...

(AI_HYDRA_LEO_MISSING_COMMA)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Run Test Suite
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (2)
CONTRIBUTING.md (1)

91-91: LGTM.

Minor formatting correction improves consistency.

.github/PULL_REQUEST_TEMPLATE.md (1)

27-29: LGTM.

PR checklist links are correctly updated to reference the new guidance sections in GUIDELINES.md. All anchor links are valid and will guide contributors appropriately.

Copy link
Contributor

@andrew-fleming andrew-fleming left a comment

Choose a reason for hiding this comment

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

Hey @emnul I see we have the docs branch 👍

we just need to remove the --filter=!'docs', right?

@emnul
Copy link
Contributor Author

emnul commented Nov 11, 2025

Currently blocked by OpenZeppelin/docs.openzeppelin.com#458


// Handle multi-line callouts
content = content.replace(
/^(TIP|NOTE):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm,

Check failure

Code scanning / CodeQL

Inefficient regular expression High documentation

This part of the regular expression may cause exponential backtracking on strings starting with 'TIP:\n' and containing many repetitions of '\n'.

Copilot Autofix

AI about 9 hours ago

To fix the inefficient regular expression, we should remove the ambiguous use of .* inside a repetition. Instead of matching "any character (possibly none), followed optionally by a \n, repeated non-greedily," we should instead use a pattern that matches any line except a blank line, corresponding to how AsciiDoc callouts work: callout paragraphs end after a double newline (\n\n) or EOF. This can be done by capturing all lines until a blank line (or EOF) appears, using a sequence that consumes full lines but does not allow blank lines. Specifically, replace the ((?:.*\n?)*?) portion with a more precise pattern such as ((?:[^\n].*(?:\n|$))*), which matches lines that are not blank. The lookahead remains unchanged to halt at a blank line or EOF. This update needs to be applied both to the TIP/NOTE and IMPORTANT|WARNING|CAUTION multi-line callout cases in the script.

Only the regular expressions in the content.replace() calls at lines 52 and 57 within docs/scripts/convert-adoc.js need to be changed.

Suggested changeset 1
docs/scripts/convert-adoc.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/docs/scripts/convert-adoc.js b/docs/scripts/convert-adoc.js
--- a/docs/scripts/convert-adoc.js
+++ b/docs/scripts/convert-adoc.js
@@ -49,12 +49,12 @@
 
 			// Handle multi-line callouts
 			content = content.replace(
-				/^(TIP|NOTE):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm,
+				/^(TIP|NOTE):\s*\n((?:[^\n].*(?:\n|$))*)(?=\n\n|$)/gm,
 				"<Callout>\n$2\n</Callout>",
 			);
 
 			content = content.replace(
-				/^(IMPORTANT|WARNING|CAUTION):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm,
+				/^(IMPORTANT|WARNING|CAUTION):\s*\n((?:[^\n].*(?:\n|$))*)(?=\n\n|$)/gm,
 				"<Callout type='warn'>\n$2\n</Callout>",
 			);
 			// Write preprocessed content
EOF
@@ -49,12 +49,12 @@

// Handle multi-line callouts
content = content.replace(
/^(TIP|NOTE):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm,
/^(TIP|NOTE):\s*\n((?:[^\n].*(?:\n|$))*)(?=\n\n|$)/gm,
"<Callout>\n$2\n</Callout>",
);

content = content.replace(
/^(IMPORTANT|WARNING|CAUTION):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm,
/^(IMPORTANT|WARNING|CAUTION):\s*\n((?:[^\n].*(?:\n|$))*)(?=\n\n|$)/gm,
"<Callout type='warn'>\n$2\n</Callout>",
);
// Write preprocessed content
Copilot is powered by AI and may make mistakes. Always verify output.
);

content = content.replace(
/^(IMPORTANT|WARNING|CAUTION):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm,

Check failure

Code scanning / CodeQL

Inefficient regular expression High documentation

This part of the regular expression may cause exponential backtracking on strings starting with 'WARNING:\n' and containing many repetitions of '\n'.

Copilot Autofix

AI about 9 hours ago

To fix the inefficient regular expression at line 57, we need to remove ambiguity in the repeated part (?:.*\n?)*?. The issue comes from using .* (which can match zero or more characters including newlines), typically inside a repetition that may match the same sequence in multiple ways. A standard way to fix this is to match lines more precisely, using patterns that cannot overlap. Since the intention seems to be to capture the body of a multi-line callout (after lines like IMPORTANT:\n, etc.) up to the next blank line or end of file, we can use a pattern such as:

((?:[^\n]*\n)*?)

Here, [^\n]*\n matches each line, and repeating this captures all lines until the lookahead assertion for double newline or end-of-string. This removes the ambiguity that exists in the original .*\n? pattern. The same fix applies to the similar regex at line 52.

Edit only lines 52 and 57 in docs/scripts/convert-adoc.js, replacing (?:.*\n?)*? with (?:[^\n]*\n)*?.


Suggested changeset 1
docs/scripts/convert-adoc.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/docs/scripts/convert-adoc.js b/docs/scripts/convert-adoc.js
--- a/docs/scripts/convert-adoc.js
+++ b/docs/scripts/convert-adoc.js
@@ -49,12 +49,12 @@
 
 			// Handle multi-line callouts
 			content = content.replace(
-				/^(TIP|NOTE):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm,
+				/^(TIP|NOTE):\s*\n((?:[^\n]*\n)*?)(?=\n\n|$)/gm,
 				"<Callout>\n$2\n</Callout>",
 			);
 
 			content = content.replace(
-				/^(IMPORTANT|WARNING|CAUTION):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm,
+				/^(IMPORTANT|WARNING|CAUTION):\s*\n((?:[^\n]*\n)*?)(?=\n\n|$)/gm,
 				"<Callout type='warn'>\n$2\n</Callout>",
 			);
 			// Write preprocessed content
EOF
@@ -49,12 +49,12 @@

// Handle multi-line callouts
content = content.replace(
/^(TIP|NOTE):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm,
/^(TIP|NOTE):\s*\n((?:[^\n]*\n)*?)(?=\n\n|$)/gm,
"<Callout>\n$2\n</Callout>",
);

content = content.replace(
/^(IMPORTANT|WARNING|CAUTION):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm,
/^(IMPORTANT|WARNING|CAUTION):\s*\n((?:[^\n]*\n)*?)(?=\n\n|$)/gm,
"<Callout type='warn'>\n$2\n</Callout>",
);
// Write preprocessed content
Copilot is powered by AI and may make mistakes. Always verify output.
.replace(/^\//, "^/")
.replace(/^(?!\^)/, "^.*");

const regex = new RegExp(pattern);

Check failure

Code scanning / CodeQL

Regular expression injection High documentation

This regular expression is constructed from a
command-line argument
.

Copilot Autofix

AI about 9 hours ago

To fix the problem, we need to ensure that user input used in the construction of a regular expression is properly escaped, so that any metacharacters are treated as literals, except for the special glob *, which is intentionally converted into .*. The best standard method is to escape user input using _.escapeRegExp from lodash, or a local equivalent if dependencies are to be minimized.

  • Specifically, on line 161 where scope is used to create pattern, first escape all regex metacharacters using an escape function, then convert escaped glob \* to .*, so that only the intended wildcard is interpreted as a regex wildcard.
  • Import escapeRegExp from lodash (or implement a local equivalent if adding a dependency is undesirable).
  • Only apply .replace(/\*/g, ".*") after escaping to make sure only * is interpreted as a wildcard.
  • Add the necessary import at the top of the file.

Suggested changeset 2
docs/scripts/link-validation.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/docs/scripts/link-validation.ts b/docs/scripts/link-validation.ts
--- a/docs/scripts/link-validation.ts
+++ b/docs/scripts/link-validation.ts
@@ -4,6 +4,7 @@
 	scanURLs,
 	validateFiles,
 } from "next-validate-link";
+import escapeRegExp from "lodash.escaperegexp";
 import type { InferPageType } from "fumadocs-core/source";
 import { source } from "@/lib/source";
 import { writeFileSync } from "fs";
@@ -158,8 +159,8 @@
 			// Convert scope pattern to regex
 			// /contracts/* becomes ^/contracts/.*
 			// contracts/* becomes ^.*contracts/.*
-			const pattern = scope
-				.replace(/\*/g, ".*")
+			const pattern = escapeRegExp(scope)
+				.replace(/\\\*/g, ".*") // Replace the escaped '*' with '.*' to act as a glob
 				.replace(/^\//, "^/")
 				.replace(/^(?!\^)/, "^.*");
 
EOF
@@ -4,6 +4,7 @@
scanURLs,
validateFiles,
} from "next-validate-link";
import escapeRegExp from "lodash.escaperegexp";
import type { InferPageType } from "fumadocs-core/source";
import { source } from "@/lib/source";
import { writeFileSync } from "fs";
@@ -158,8 +159,8 @@
// Convert scope pattern to regex
// /contracts/* becomes ^/contracts/.*
// contracts/* becomes ^.*contracts/.*
const pattern = scope
.replace(/\*/g, ".*")
const pattern = escapeRegExp(scope)
.replace(/\\\*/g, ".*") // Replace the escaped '*' with '.*' to act as a glob
.replace(/^\//, "^/")
.replace(/^(?!\^)/, "^.*");

docs/package.json
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/docs/package.json b/docs/package.json
--- a/docs/package.json
+++ b/docs/package.json
@@ -52,7 +52,8 @@
 		"remark-mdx": "^3.1.1",
 		"shiki": "^3.12.2",
 		"tailwind-merge": "^3.3.1",
-		"unist-util-visit": "^5.0.0"
+		"unist-util-visit": "^5.0.0",
+		"lodash.escaperegexp": "^4.1.2"
 	},
 	"devDependencies": {
 		"@biomejs/biome": "^2.2.4",
EOF
@@ -52,7 +52,8 @@
"remark-mdx": "^3.1.1",
"shiki": "^3.12.2",
"tailwind-merge": "^3.3.1",
"unist-util-visit": "^5.0.0"
"unist-util-visit": "^5.0.0",
"lodash.escaperegexp": "^4.1.2"
},
"devDependencies": {
"@biomejs/biome": "^2.2.4",
This fix introduces these dependencies
Package Version Security advisories
lodash.escaperegexp (npm) 4.1.2 None
Copilot is powered by AI and may make mistakes. Always verify output.

// Handle multi-line callouts
content = content.replace(
/^(TIP|NOTE):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm,

Check failure

Code scanning / CodeQL

Inefficient regular expression High documentation

This part of the regular expression may cause exponential backtracking on strings starting with 'TIP:\n' and containing many repetitions of '\n'.

Copilot Autofix

AI about 9 hours ago

The problematic part is ((?:.*\n?)*?) which may cause exponential backtracking. The intent is to capture multiple lines after a callout start ("TIP:" or "NOTE:") up to a blank line or end of string.

To fix this, instead of using nested repetitions and ambiguous patterns, match each line individually using a non-greedy pattern that captures all lines until a double newline (\n\n) or end of string. This can be achieved reliably by matching one or more lines that do not themselves constitute a blank line.

Replace the original pattern:

/^(TIP|NOTE):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm

with a safer one using:

/^(TIP|NOTE):\s*\n((?:[^\n].*\n?)*)/gm

Here, [^\n].*\n? matches a line with at least one character, and the outer repetition collects all such lines; this avoids ambiguity in matching the repeated lines and prevents backtracking caused by .* with nested quantifiers. Optionally, to ensure we don't include blank lines, we can stop at a double newline using a lookahead, as in the original, but in a less ambiguous way:

/^(TIP|NOTE):\s*\n([\s\S]*?)(?=\n\n|$)/gm

Here, [\s\S]*? is a common idiom in JavaScript regex for matching any character (including newlines) non-greedily, up to the next double newline or end of string. This is not ambiguous and avoids catastrophic backtracking. We'll use this form for maximum compatibility.

Only line 43 in docs/scripts/process-mdx.js needs to be changed; no imports or further changes are required.


Suggested changeset 1
docs/scripts/process-mdx.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/docs/scripts/process-mdx.js b/docs/scripts/process-mdx.js
--- a/docs/scripts/process-mdx.js
+++ b/docs/scripts/process-mdx.js
@@ -40,7 +40,7 @@
 
       // Handle multi-line callouts
       content = content.replace(
-        /^(TIP|NOTE):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm,
+        /^(TIP|NOTE):\s*\n([\s\S]*?)(?=\n\n|$)/gm,
         "<Callout>\n$2\n</Callout>",
       );
 
EOF
@@ -40,7 +40,7 @@

// Handle multi-line callouts
content = content.replace(
/^(TIP|NOTE):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm,
/^(TIP|NOTE):\s*\n([\s\S]*?)(?=\n\n|$)/gm,
"<Callout>\n$2\n</Callout>",
);

Copilot is powered by AI and may make mistakes. Always verify output.
);

content = content.replace(
/^(IMPORTANT|WARNING|CAUTION):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm,

Check failure

Code scanning / CodeQL

Inefficient regular expression High documentation

This part of the regular expression may cause exponential backtracking on strings starting with 'WARNING:\n' and containing many repetitions of '\n'.

Copilot Autofix

AI about 9 hours ago

To fix the inefficiency, we should rewrite the problematic part: ((?:.*\n?)*?). The intent seems to be: "capture all content following an 'IMPORTANT', 'WARNING', or 'CAUTION' label and a newline, up to the next blank line or end of input."
Instead of using .*\n?, which can match newlines in ambiguous ways, we should match lines one-by-one: (?:[^\n]*\n?)*? matches non-newline characters followed optionally by a newline, and is unambiguous.
Thus, change (.*\n?)*? to ([^\n]*\n?)*? in both line 48 and the analogous case on line 43 (for TIP/NOTE).

Edit only the regex in the relevant content.replace calls. Nothing else needs to change.


Suggested changeset 1
docs/scripts/process-mdx.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/docs/scripts/process-mdx.js b/docs/scripts/process-mdx.js
--- a/docs/scripts/process-mdx.js
+++ b/docs/scripts/process-mdx.js
@@ -40,12 +40,12 @@
 
       // Handle multi-line callouts
       content = content.replace(
-        /^(TIP|NOTE):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm,
+        /^(TIP|NOTE):\s*\n((?:[^\n]*\n?)*?)(?=\n\n|$)/gm,
         "<Callout>\n$2\n</Callout>",
       );
 
       content = content.replace(
-        /^(IMPORTANT|WARNING|CAUTION):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm,
+        /^(IMPORTANT|WARNING|CAUTION):\s*\n((?:[^\n]*\n?)*?)(?=\n\n|$)/gm,
         "<Callout type='warn'>\n$2\n</Callout>",
       );
       // Fix HTML entities globally
EOF
@@ -40,12 +40,12 @@

// Handle multi-line callouts
content = content.replace(
/^(TIP|NOTE):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm,
/^(TIP|NOTE):\s*\n((?:[^\n]*\n?)*?)(?=\n\n|$)/gm,
"<Callout>\n$2\n</Callout>",
);

content = content.replace(
/^(IMPORTANT|WARNING|CAUTION):\s*\n((?:.*\n?)*?)(?=\n\n|$)/gm,
/^(IMPORTANT|WARNING|CAUTION):\s*\n((?:[^\n]*\n?)*?)(?=\n\n|$)/gm,
"<Callout type='warn'>\n$2\n</Callout>",
);
// Fix HTML entities globally
Copilot is powered by AI and may make mistakes. Always verify output.
function processFile(filePath) {
try {
const content = fs.readFileSync(filePath, "utf8");
const updatedContent = content.replace(/```rust/g, "```rust");

Check warning

Code scanning / CodeQL

Replacement of a substring with itself Medium documentation

This replaces '```rust' with itself.

Copilot Autofix

AI about 9 hours ago

To fix the issue, determine the intended transformation for the string "rust". If the intention is to escape quotes, convert code fences from "rust" to another language (e.g., "```cairo"), or apply any other specific transformation, the replacement string should reflect that. Since the script is named "cairo-convert", it is very likely meant to convert Rust code fences to Cairo code fences in the docs:

  • General fix: Change the replacement string from "rust" to the intended value, such as "cairo", so that all "rust" code blocks in Markdown are converted to "cairo" blocks.
  • Detailed steps:
    • Edit docs/scripts/cairo-convert.js at line 22.
    • Change the replacement code to:
      const updatedContent = content.replace(/```rust/g, "```cairo");
  • No new imports or definitions are required; just the single line edit.

Suggested changeset 1
docs/scripts/cairo-convert.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/docs/scripts/cairo-convert.js b/docs/scripts/cairo-convert.js
--- a/docs/scripts/cairo-convert.js
+++ b/docs/scripts/cairo-convert.js
@@ -19,7 +19,7 @@
 function processFile(filePath) {
 	try {
 		const content = fs.readFileSync(filePath, "utf8");
-		const updatedContent = content.replace(/```rust/g, "```rust");
+		const updatedContent = content.replace(/```rust/g, "```cairo");
 
 		if (content !== updatedContent) {
 			fs.writeFileSync(filePath, updatedContent, "utf8");
EOF
@@ -19,7 +19,7 @@
function processFile(filePath) {
try {
const content = fs.readFileSync(filePath, "utf8");
const updatedContent = content.replace(/```rust/g, "```rust");
const updatedContent = content.replace(/```rust/g, "```cairo");

if (content !== updatedContent) {
fs.writeFileSync(filePath, updatedContent, "utf8");
Copilot is powered by AI and may make mistakes. Always verify output.
git-subtree-dir: docs
git-subtree-split: f1cf40f52fe7be77fbc603b90051262c78990556
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate Docs Directory

3 participants