-
Notifications
You must be signed in to change notification settings - Fork 65
chore: improved index page #1045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
avivkeller
wants to merge
5
commits into
main
Choose a base branch
from
index
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@doc-kit/generator-react': patch | ||
| --- | ||
|
|
||
| Add a `<DocumentationIndex />` MDX component that renders the stability overview of every module, backed by a new `documentationIndex` export on `#theme/config` (replaces the `<!-- DOCUMENTATION_INDEX -->` comment) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@doc-kit/core': patch | ||
| --- | ||
|
|
||
| MDX nodes in the HTML-string pipelines are now dropped, and do not crash. |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import assert from 'node:assert/strict'; | ||
| import { describe, it } from 'node:test'; | ||
|
|
||
| import { getRemarkRehype } from '../remark.mjs'; | ||
|
|
||
| describe('getRemarkRehype', () => { | ||
| it('degrades MDX nodes instead of crashing rehype-stringify', () => { | ||
| const processor = getRemarkRehype(); | ||
|
|
||
| const tree = { | ||
| type: 'root', | ||
| children: [ | ||
| { | ||
| type: 'paragraph', | ||
| children: [ | ||
| { type: 'text', value: 'before ' }, | ||
| { | ||
| type: 'mdxJsxTextElement', | ||
| name: 'Tooltip', | ||
| attributes: [], | ||
| children: [{ type: 'text', value: 'inner' }], | ||
| }, | ||
| { type: 'mdxTextExpression', value: '1 + 1' }, | ||
| ], | ||
| }, | ||
| { | ||
| type: 'mdxJsxFlowElement', | ||
| name: 'DocumentationIndex', | ||
| attributes: [], | ||
| children: [], | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| const output = processor.stringify(processor.runSync(tree)); | ||
|
|
||
| // JSX elements degrade to their children; expressions are dropped. | ||
| assert.equal(output, '<p>before inner</p>'); | ||
| }); | ||
| }); |
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
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
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
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
48 changes: 48 additions & 0 deletions
48
packages/react/src/html/ui/components/DocumentationIndex/index.jsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import Badge from '@node-core/ui-components/Common/Badge'; | ||
|
|
||
| import styles from './index.module.css'; | ||
| import { STABILITY_KINDS, STABILITY_LABELS } from '../constants.mjs'; | ||
|
|
||
| import { documentationIndex } from '#theme/config'; | ||
|
|
||
| /** | ||
| * @typedef {Object} DocumentationIndexEntry | ||
| * @property {string} api - Basename of the document, linked as `${api}.html` | ||
| * @property {string} name - Human-readable name from the document's heading | ||
| * @property {string} index - Stability index (e.g. `'2'` or `'1.1'`) | ||
| * @property {string} [description] - The document's `llm_description`, or its first paragraph | ||
| */ | ||
|
|
||
| /** | ||
| * @param {DocumentationIndexEntry} props | ||
| */ | ||
| const IndexEntry = ({ api, name, index, description }) => { | ||
| const level = parseInt(index, 10); | ||
| const label = STABILITY_LABELS[level] ?? index; | ||
|
|
||
| return ( | ||
| <a className={styles.entry} href={`${api}.html`}> | ||
| <span className={styles.title}> | ||
| <span className={styles.name}>{name}</span> | ||
|
|
||
| <Badge | ||
| size="small" | ||
| kind={STABILITY_KINDS[level] ?? 'neutral'} | ||
| aria-label={`Stability: ${index}`} | ||
| > | ||
| {label} | ||
| </Badge> | ||
| </span> | ||
|
|
||
| {description && <span className={styles.summary}>{description}</span>} | ||
| </a> | ||
| ); | ||
| }; | ||
|
|
||
| export default () => ( | ||
| <nav className={styles.documentationIndex} aria-label="Documentation index"> | ||
| {documentationIndex.map(entry => ( | ||
| <IndexEntry key={entry.api} {...entry} /> | ||
| ))} | ||
| </nav> | ||
| ); |
61 changes: 61 additions & 0 deletions
61
packages/react/src/html/ui/components/DocumentationIndex/index.module.css
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| .documentationIndex { | ||
| display: grid; | ||
| grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); | ||
| gap: 1rem; | ||
| margin-block: 1.5rem; | ||
| } | ||
|
|
||
| .entry { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: 0.375rem; | ||
| padding: 1rem; | ||
| border: 1px solid var(--color-neutral-200); | ||
| border-radius: 0.75rem; | ||
| color: inherit; | ||
| text-decoration: none; | ||
| transition: | ||
| border-color 0.15s ease, | ||
| background-color 0.15s ease; | ||
| } | ||
|
|
||
| .entry:hover, | ||
| .entry:focus-visible { | ||
| border-color: var(--color-neutral-400); | ||
| background-color: var(--color-neutral-100); | ||
| } | ||
|
|
||
| :where([data-theme='dark'], [data-theme='dark'] *) .entry { | ||
| border-color: var(--color-neutral-900); | ||
| } | ||
|
|
||
| :where([data-theme='dark'], [data-theme='dark'] *) .entry:hover, | ||
| :where([data-theme='dark'], [data-theme='dark'] *) .entry:focus-visible { | ||
| border-color: var(--color-neutral-700); | ||
| background-color: var(--color-neutral-950); | ||
| } | ||
|
|
||
| .title { | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: space-between; | ||
| gap: 0.5rem; | ||
| } | ||
|
|
||
| .name { | ||
| font-weight: 600; | ||
| color: var(--color-neutral-900); | ||
| } | ||
|
|
||
| :where([data-theme='dark'], [data-theme='dark'] *) .name { | ||
| color: var(--color-white); | ||
| } | ||
|
|
||
| .summary { | ||
| font-size: 0.875rem; | ||
| color: var(--color-neutral-800); | ||
| } | ||
|
|
||
| :where([data-theme='dark'], [data-theme='dark'] *) .summary { | ||
| color: var(--color-neutral-600); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this DocumentationIndex sort of component just for Node, or going to be kinda part of standard doc-kit components? I feel that all the components doc-kit exposes on our web generator should be documented under the web generator docs [...]
I also feel tha this name "DocumentationIndex" doesn't really say what this component renders, can we have a more descriptive name for the component, tgat'd b great
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a standard doc kit component. The name
DocumentationIndexis fairly descriptive of what the component does: Documentation IndexThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I unfortunately disagree. "Documentation Index" isn't fairly descriptive, and doesn't say what is rendered. What is in this "documentation index"? I feel that a proper name is "StabilityOverview" or "DocumentationModulesOverview" or something more descriptive.