fix(docs): resolved markdown for function Copy Page - #495
Open
geril07 wants to merge 4 commits into
Open
Conversation
…down Generate AI-ready per-function markdown at build time, skip static MDX mirroring for function pages so it is not clobbered, and wire Copy Page to the public share artifact instead of raw MDX shells.
…n page Match interactive page order: demo, Installation (with manual source), Usage, Type Declarations, API, Contributors. Drop invented Source/Demo/ Dependencies headings.
Match the page FunctionApi layout: Parameters table (Name, Type, Default, Note) and Returns per overload group.
Align source and type declaration code fences with the page (tsx).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Дисклеймер
Сгенерировано ИИ, ревью от человека поверхностное + небольшие смоук-тесты.
Для референса брался shadcn/ui (Copy Page / View as Markdown / resolved page content).
Дальше от ИИ:
В PR только код (
generate-functions,generate-static,page.tsx).Массовый diff
public/functions/**/*.md(~177 файлов) не включён, чтобы ревью было читаемым.После ревью — автоген поверх или отдельным follow-up.
Зачем
На страницах функций Copy Page копировал внутренний MDX-shell, а не документацию. Текст почти бесполезен для AI и шаринга. Тот же shell отдавался как View as Markdown.
Нужен один resolved markdown-артефакт на функцию: полезный контент, порядок секций как на странице (в духе shadcn).
Closes #494
Что сделано
generate-functions(plain source/types/demo/API → md).generate-staticне перезаписываетpublic/functions/**MDX-shell'ами.public/functions/{hooks|helpers}/{name}.mdвместоgetText('raw').public/functions/**заложена в генераторе (сами файлы — follow-up / автоген после ревью).Структура md (как страница):
## Demo)## Installation— library, CLI, manual + source## Usage## Type Declarations## API— таблицы Parameters / Returns (какFunctionApi), overloads## ContributorsКак проверить
/functions/hooks/useCopy.md— секции как на странице, есть source/API-таблица, нетimport metadata/functions/hooks/useCopy— тот же текст, что.mduseActiveElement.md— overload-группы в APIpnpm run generate:staticне затирает share-mdВерификация
Что смотрели
createShareMarkdown/createShareApiMarkdown,createMdxTemplate,function-api.tsx,page.tsx,generate-staticskippublic/functions/**/*.md(shell-маркеры, banned H2, parity mdx↔md, API-таблицы, fences)useCopy,useActiveElement(overloads),useQuery(богатый API), helpers (cn,createContext), warning (useOnce), returns-only / no-APIpnpm dev :4000— curl HTML +.md, Playwright outlines H2/H3, RSC payload Copy Page == disk.mdclipboard.writeText(resolved md, не shell)Как
rgпо shell/H2, сверка outline, сравнение с MDX/metagenerate:staticне clobber'ит share-mdИтог проверки
PASS WITH GAPS — match со страницей достаточный; blockers нет.
Несоответствия page ↔ md (не правили)
*.demo.tsxбез## Demo— интерактив в clipboard не переносится; source demo = shadcn-подход с ComponentPreview. Отдельного## Demoна странице нет.FunctionApiв основном type — description уже в данных; для AI полезнее. Строгий 1:1 с UI не критичен.Не автоматизировано в последнем прогоне
.md)Коммиты
fix(docs): resolve function Copy Page from share markdownfix(docs): align share markdown sections with function pagefix(docs): render share markdown API as tablesfix(docs): use tsx fences in function share markdownАвтоген
public/functions/**в PR не входит (см. секцию выше).Зачем каждое изменение
packages/newdocs/scripts/generate-functions.tsЗачем: единственное место с plain source, types, demo и JSDoc API до Shiki/HTML.
Почему так: UI остаётся MDX + meta; для Copy/AI нужен линейный md. Build-time generation = пайплайн репо, без runtime-резолва JSX.
Что внутри:
createShareMarkdown— порядок секций как у страницыcreateShareApiMarkdown— таблицы API какFunctionApipublic/functions/..., prune stale shellstsx/bashpackages/newdocs/scripts/generate-static.tsЗачем: раньше копировал весь
content/**/*.mdx→public/**/*.md, в т.ч. function shells.Почему обязательно: идёт после
generate-functionsи без skip затирал resolved md.Что внутри: skip
functions/.packages/newdocs/app/(docs)/functions/[[...slug]]/page.tsxЗачем: сюда приходит строка для Copy Page.
Почему так:
FunctionHeaderуже делаетcopy(markdown); меняем источник на тот же файл, что и.mdURL → Copy и View as Markdown не расходятся.Что внутри:
readFile(public/functions/{type}s/{name}.md)вместоgetText('raw').packages/newdocs/public/functions/**/*.md(не в этом PR)Зачем: resolved share-md для Copy Page / View as Markdown (tracked gen в репо).
Почему не здесь: ~177 файлов зашумляют diff; после ревью — автоген поверх или отдельным follow-up.