Skip to content

Conversation

@sacOO7
Copy link
Contributor

@sacOO7 sacOO7 commented Jan 26, 2026

Summary by CodeRabbit

  • Tests

    • Added comprehensive test coverage for documentation link conversion during build processing, covering .md addition for /docs links, stripping query parameters, preserving anchors, nested docs paths, relative URLs, and edge cases with existing extensions and trailing slashes.
  • Chores

    • Improved documentation-link processing in the build pipeline to normalize /docs URLs to .md while preserving navigation anchors and removing irrelevant query parameters.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 26, 2026

Important

Review skipped

Auto 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.

  • 🔍 Trigger a full review

Walkthrough

A new exported utility convertDocsLinksToMarkdown was added and integrated into the MDX-to-Markdown pipeline; it rewrites Ably /docs/ absolute links to use .md, strips query parameters, preserves hash anchors, skips non-docs/other-file links, and has comprehensive tests added.

Changes

Cohort / File(s) Summary
Docs Link Conversion Implementation
data/onPostBuild/transpileMdxToMarkdown.ts
Added and exported convertDocsLinksToMarkdown(content: string) that converts absolute http(s) /docs/ links for ably.com and ably-dev.com to .md, removes query parameters, preserves hash fragments, skips already-.md or non-doc extensions, normalizes trailing slashes, and integrated it into the transformation pipeline (applied after relative URL conversion and before template variable replacement).
Docs Link Conversion Tests
data/onPostBuild/transpileMdxToMarkdown.test.ts
Added extensive tests importing the new export to verify conversions across scenarios: adding .md to /docs/ links, stripping ? queries, preserving # anchors, nested /docs/ paths, avoiding non-docs links, handling trailing slashes, existing .md extensions, various hostnames (including ably-dev.com), relative URLs, and links with other file extensions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hoppity-hop, the links now care,

From /docs/ paths to .md fair,
Queries trimmed and anchors kept,
Paths neatly normalized and leapt,
A rabbit’s cheer for tidy doc fare 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: converting HTML links to explicit markdown links in generated markdown pages.
Linked Issues check ✅ Passed The code changes implement the core requirement from FTF-535 by adding a utility function that converts documentation links to markdown format with .md extensions.
Out of Scope Changes check ✅ Passed All changes are within scope: a new helper function for converting docs links to markdown format and its integration into the transformation pipeline.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@sacOO7 sacOO7 changed the title Fixed Generated markdown pages to have explicit markdown links Fix generated markdown pages to have explicit markdown links Jan 26, 2026
@sacOO7
Copy link
Contributor Author

sacOO7 commented Jan 26, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 26, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 2

🤖 Fix all issues with AI agents
In `@data/onPostBuild/transpileMdxToMarkdown.test.ts`:
- Around line 417-433: The long string literals in the tests for
convertDocsLinksToMarkdown (the consts named input in the three failing it
blocks) exceed Prettier's line length; refactor each long input assignment into
multiple concatenated string segments (e.g. const input =
'https://raw.github...' + '/more/path' ) or use short concatenation so the final
value is identical but no single source line is too long, leaving the output
assertions and convertDocsLinksToMarkdown calls unchanged.

In `@data/onPostBuild/transpileMdxToMarkdown.ts`:
- Around line 333-375: The link-rewrite in convertDocsLinksToMarkdown is using
naive string checks and can misidentify non‑Ably domains and produce trailing
'/.md'; fix by parsing the url with the URL constructor (or a safe parse
fallback) to validate the hostname is an Ably docs host (e.g.,
endsWith('ably.com') or endsWith('ably-dev.com') but exclude 'sdk.ably.com'),
then reconstruct the target by taking url.pathname (trim any trailing '/') and
appending '.md', preserving the original hash (anchor) but dropping query params
as before; update all checks in convertDocsLinksToMarkdown to operate on the
parsed URL object and return the original match if the host/path validation
fails.
🧹 Nitpick comments (1)
data/onPostBuild/transpileMdxToMarkdown.ts (1)

333-376: Consider skipping fenced code blocks during link conversion.

Other transforms preserve code blocks, but this function rewrites all Markdown links, including those inside ``` fences. That can alter code examples unintentionally. Consider splitting by fenced blocks and only converting non‑code sections.

Comment on lines 417 to 433
it('should not modify sdk.ably.com links (API documentation)', () => {
const input = '[Room](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Room.html)';
const output = convertDocsLinksToMarkdown(input);
expect(output).toBe('[Room](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Room.html)');
});

it('should not modify sdk.ably.com links with /docs/ in path', () => {
const input = '[Docs](https://sdk.ably.com/docs/some-path)';
const output = convertDocsLinksToMarkdown(input);
expect(output).toBe('[Docs](https://sdk.ably.com/docs/some-path)');
});

it('should not add .md to URLs that already have a file extension (.png)', () => {
const input = '[Image](https://raw.githubusercontent.com/ably/docs/main/src/images/content/diagrams/test.png)';
const output = convertDocsLinksToMarkdown(input);
expect(output).toBe('[Image](https://raw.githubusercontent.com/ably/docs/main/src/images/content/diagrams/test.png)');
});
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix Prettier violations for long string literals.

The linter reports formatting errors on the long test strings. Reformatting to multiline assignments should clear the Prettier errors.

🧹 Proposed fix
-      const input = '[Room](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Room.html)';
+      const input =
+        '[Room](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Room.html)';
@@
-      const input = '[Image](https://raw.githubusercontent.com/ably/docs/main/src/images/content/diagrams/test.png)';
+      const input =
+        '[Image](https://raw.githubusercontent.com/ably/docs/main/src/images/content/diagrams/test.png)';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it('should not modify sdk.ably.com links (API documentation)', () => {
const input = '[Room](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Room.html)';
const output = convertDocsLinksToMarkdown(input);
expect(output).toBe('[Room](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Room.html)');
});
it('should not modify sdk.ably.com links with /docs/ in path', () => {
const input = '[Docs](https://sdk.ably.com/docs/some-path)';
const output = convertDocsLinksToMarkdown(input);
expect(output).toBe('[Docs](https://sdk.ably.com/docs/some-path)');
});
it('should not add .md to URLs that already have a file extension (.png)', () => {
const input = '[Image](https://raw.githubusercontent.com/ably/docs/main/src/images/content/diagrams/test.png)';
const output = convertDocsLinksToMarkdown(input);
expect(output).toBe('[Image](https://raw.githubusercontent.com/ably/docs/main/src/images/content/diagrams/test.png)');
});
it('should not modify sdk.ably.com links (API documentation)', () => {
const input =
'[Room](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Room.html)';
const output = convertDocsLinksToMarkdown(input);
expect(output).toBe('[Room](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Room.html)');
});
it('should not modify sdk.ably.com links with /docs/ in path', () => {
const input = '[Docs](https://sdk.ably.com/docs/some-path)';
const output = convertDocsLinksToMarkdown(input);
expect(output).toBe('[Docs](https://sdk.ably.com/docs/some-path)');
});
it('should not add .md to URLs that already have a file extension (.png)', () => {
const input =
'[Image](https://raw.githubusercontent.com/ably/docs/main/src/images/content/diagrams/test.png)';
const output = convertDocsLinksToMarkdown(input);
expect(output).toBe('[Image](https://raw.githubusercontent.com/ably/docs/main/src/images/content/diagrams/test.png)');
});
🧰 Tools
🪛 ESLint

[error] 420-420: Replace '[Room](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Room.html)' with ⏎········'[Room](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Room.html)',⏎······

(prettier/prettier)


[error] 432-432: Replace '[Image](https://raw.githubusercontent.com/ably/docs/main/src/images/content/diagrams/test.png)' with ⏎········'[Image](https://raw.githubusercontent.com/ably/docs/main/src/images/content/diagrams/test.png)',⏎······

(prettier/prettier)

🤖 Prompt for AI Agents
In `@data/onPostBuild/transpileMdxToMarkdown.test.ts` around lines 417 - 433, The
long string literals in the tests for convertDocsLinksToMarkdown (the consts
named input in the three failing it blocks) exceed Prettier's line length;
refactor each long input assignment into multiple concatenated string segments
(e.g. const input = 'https://raw.github...' + '/more/path' ) or use short
concatenation so the final value is identical but no single source line is too
long, leaving the output assertions and convertDocsLinksToMarkdown calls
unchanged.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the MDX→Markdown post-build pipeline so that Ably documentation links in generated .md files use explicit markdown links pointing to .md resources, making them friendlier for LLM consumption.

Changes:

  • Introduced convertDocsLinksToMarkdown to normalize Ably /docs/ links: stripping query parameters (e.g. ?lang=), preserving hash anchors, avoiding .md on assets, and skipping sdk.ably.com.
  • Integrated the new link conversion step into the transformMdxToMarkdown pipeline after relative URL expansion.
  • Added comprehensive unit tests for convertDocsLinksToMarkdown, covering different domains, query parameters, anchors, nested paths, multiple links, and asset/file extensions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
data/onPostBuild/transpileMdxToMarkdown.ts Adds convertDocsLinksToMarkdown and wires it into the MDX→Markdown transform flow, updating stage comments and exports.
data/onPostBuild/transpileMdxToMarkdown.test.ts Extends the test suite with detailed cases for the new link conversion behavior, alongside existing pipeline utility tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

1. Updated script to replace generated markdown page containing ably html
doc links with corresponding markdown link
2. Added relevant unit tests for the same
@sacOO7 sacOO7 force-pushed the fix/generated-markdown-page-links branch from bb8fd35 to 1bd5fc1 Compare January 26, 2026 16:46
@sacOO7 sacOO7 requested a review from Copilot January 26, 2026 17:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sacOO7
Copy link
Contributor Author

sacOO7 commented Jan 27, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@sacOO7 sacOO7 marked this pull request as ready for review January 28, 2026 09:14
@sacOO7 sacOO7 requested a review from GregHolmes January 28, 2026 09:14
- Removed unnecessary unit tests from transpileMdxToMarkdown
@sacOO7
Copy link
Contributor Author

sacOO7 commented Jan 29, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-app Create a Heroku review app

Development

Successfully merging this pull request may close these issues.

4 participants