Skip to content

doc: fix autoLink function, dont autolink from headers#6056

Merged
jonchurch merged 2 commits intolodash:mainfrom
jonchurch:jonchurch/doc-html-fixes
Dec 4, 2025
Merged

doc: fix autoLink function, dont autolink from headers#6056
jonchurch merged 2 commits intolodash:mainfrom
jonchurch:jonchurch/doc-html-fixes

Conversation

@jonchurch
Copy link
Member

@jonchurch jonchurch commented Dec 2, 2025

This PR is for the tooling historically used to generate the HTML for the doc site

Problem

The weirdness we saw in lodash/lodash.com#300 (comment) was related to bugs in the preprocess and postprocess step in this repo when generating the doc site html.

We saw some md links to the source code not being converted into html, and double links in the h3s for some methods (the anchor link, then the h3 content itself wrapped in a link).

Solution

Change 1: the issue was that the preprocess step was only converting the md links that had both a source and an npm package link. The regexp just was too strict, and didnt match on the API surfaces that had a source link but no npm link (bc there is no npm package for things like _.VERSION)

Change 2: exclude headers from the autolinking behavior. The selector there was matching anything in
.doc-container code that looked like a reference to a lodash method. But that also caught several headers.

Context

The process when running npm run doc:sitehtml goes:

  • Generate markdown from the JSDoc (using docdown), writes to doc/README.md
  • Preprocess said generated markdown in the lib/main/build-site.js script
    • Change 1 of this PR is at this step, converting md links like [source](the github source...) into html links
  • Run that markdown through marky-markdown
  • Run a postprocess step on the html
    • Change 2 of this PR was here, tweak the autolinking behavior when referencing a lodash method in doc body

@jonchurch jonchurch force-pushed the jonchurch/doc-html-fixes branch from 71c99d0 to adb32a0 Compare December 2, 2025 20:44
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

we should definitely convert this to something less "parse regex from html"ish

@falsyvalues
Copy link
Member

we should definitely convert this to something less "parse regex from html"ish

And add some smoke tests for this part.

@jonchurch jonchurch force-pushed the jonchurch/doc-html-fixes branch from adb32a0 to c018667 Compare December 4, 2025 19:13
@jonchurch
Copy link
Member Author

just signed my existing commits and force pushed 🔐

@jonchurch jonchurch merged commit 4879a7a into lodash:main Dec 4, 2025
30 checks passed
@jonchurch jonchurch deleted the jonchurch/doc-html-fixes branch December 4, 2025 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants