Skip to content

fix(processor): resolve malformed URLs and incomplete type mapping#19

Open
moshams272 wants to merge 2 commits intowebpack:mainfrom
moshams272:main
Open

fix(processor): resolve malformed URLs and incomplete type mapping#19
moshams272 wants to merge 2 commits intowebpack:mainfrom
moshams272:main

Conversation

@moshams272
Copy link

@moshams272 moshams272 commented Mar 13, 2026

Summary

This PR addresses Issue #3 regarding malformed URLs and incomplete type mapping in the generated type-map.json file.

Problems Solved:

Malformed URLs: TypeDoc sometimes generates URLs with multiple hash fragments (e.g., globals.html#compiler-1#webpack), which leads to broken links in the final documentation.

Incomplete Mapping: The previous implementation failed to resolve nested types or full names, causing gaps in the type-map where JSDoc references couldn't be matched.

Changes:

Modularized the logic by introducing a cleanTypeDocUrl helper function.

Implemented a safe .md to .html extension replacement using Regex to avoid accidental matches in filenames (e.g., utils.md5.md).

Added a hash-cleaning logic that preserves the base path and the final, most specific anchor.

Updated the processor to register both shortName and fullName (via ref.getFullName()) for all reflections, ensuring full coverage for JSDoc references.

What kind of change does this PR introduce?

A fix and refactor. It fixes the broken URL generation and refactors the mapping logic for better maintainability and performance.

Did you add tests for your changes?

Verified the changes by running npm run generate-docs against the webpack source and manually inspecting the resulting type-map.json to ensure all URLs are well-formed and all types are correctly mapped.

Does this PR introduce a breaking change?

No.

If relevant, what needs to be documented once your changes are merged or what have you already documented?

N/A (This is a fix for the internal documentation toolchain).

Use of AI

I used an AI collaborator to help brainstorm the regex patterns and refactor the code into a more modular structure. The AI assisted in identifying edge cases for URL fragments and ensuring the code adheres to clean-code principles, while All technical investigations, local builds, and final code changes were performed and verified by me manually.

@moshams272 moshams272 requested a review from avivkeller March 14, 2026 00:48
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.

2 participants