Skip to content
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

[docs-infra] Enforce punctuation on descriptions #44292

Merged
merged 2 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/data/material/integrations/nextjs/nextjs.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Next.js integration

<p class="description">Learn how to use Material UI with Next.js</p>
<p class="description">Learn how to use Material UI with Next.js.</p>

## App Router

Expand Down
6 changes: 6 additions & 0 deletions packages/markdown/prepareMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ function prepareMarkdown(config) {
);
}

if (description.slice(-1) !== '.' && description.slice(-1) !== '!') {
throw new Error(
`docs-infra: The description "${description}" should end with a "." or "!", those are sentences.`,
);
}

const contents = getContents(markdown);

if (headers.unstyled) {
Expand Down
28 changes: 14 additions & 14 deletions packages/markdown/prepareMarkdown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('prepareMarkdown', () => {
const markdown = `
# Support

<p class="description">Foo</p>
<p class="description">Foo.</p>

## Community help (free)
### GitHub <img src="/static/images/logos/github.svg" width="24" height="24" alt="GitHub logo" loading="lazy" />
Expand Down Expand Up @@ -64,7 +64,7 @@ describe('prepareMarkdown', () => {
const markdown = `
# Theming

<p class="description">Foo</p>
<p class="description">Foo.</p>

## API
### responsiveFontSizes(theme, options) => theme
Expand Down Expand Up @@ -105,7 +105,7 @@ describe('prepareMarkdown', () => {
const markdownEn = `
# Localization

<p class="description">Foo</p>
<p class="description">Foo.</p>

## Locales
### Example
Expand All @@ -115,7 +115,7 @@ describe('prepareMarkdown', () => {
const markdownPt = `
# Localização

<p class="description">Foo</p>
<p class="description">Foo.</p>

## Idiomas
### Exemplo
Expand All @@ -125,7 +125,7 @@ describe('prepareMarkdown', () => {
const markdownZh = `
# 所在位置

<p class="description">Foo</p>
<p class="description">Foo.</p>

## 语言环境
### 例
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('prepareMarkdown', () => {
const markdownEn = `
# Localization

<p class="description">Foo</p>
<p class="description">Foo.</p>

## Locales
### Example
Expand All @@ -221,7 +221,7 @@ describe('prepareMarkdown', () => {
const markdownPt = `
# Localização

<p class="description">Foo</p>
<p class="description">Foo.</p>

## Idiomas
### Exemplo
Expand Down Expand Up @@ -292,7 +292,7 @@ describe('prepareMarkdown', () => {
const markdown = `
# Localization

<p class="description">Foo</p>
<p class="description">Foo.</p>

[bar](/bar/)
[foo](/foo)
Expand All @@ -314,7 +314,7 @@ See https://ahrefs.com/blog/trailing-slash/ for more details.
const markdown = `
# Localization

<p class="description">Foo</p>
<p class="description">Foo.</p>

[bar](/bar/)
[foo](foo/)
Expand All @@ -334,7 +334,7 @@ See https://ahrefs.com/blog/trailing-slash/ for more details.
const markdown = `
# Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

<p class="description">Foo</p>
<p class="description">Foo.</p>

`;

Expand All @@ -354,7 +354,7 @@ https://developers.google.com/search/docs/advanced/appearance/title-link
const markdown = `
# Foo

<p class="description">Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo</p>
<p class="description">Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.</p>

`;

Expand All @@ -364,7 +364,7 @@ https://developers.google.com/search/docs/advanced/appearance/title-link
translations: [{ filename: 'index.md', markdown, userLanguage: 'en' }],
});
}).to
.throw(`docs-infra: The description "Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" is too long (188 characters).
.throw(`docs-infra: The description "Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo." is too long (188 characters).
It needs to have fewer than 170 characters—ideally less than 160. For more details, see:
https://ahrefs.com/blog/meta-description/#4-be-concise
`);
Expand All @@ -374,7 +374,7 @@ https://ahrefs.com/blog/meta-description/#4-be-concise
const markdown = `
# Foo

<p class="description">Fo</p>
<p class="description">Fo.</p>

\`\`\`sh
npm install @mui/material
Expand All @@ -401,7 +401,7 @@ Use "bash" instead.
const markdown = `
# Localization

<p class="description">Foo</p>
<p class="description">Foo.</p>

[foo](/foo/)
[bar](/bar//#foo)
Expand Down