Skip to content

Commit 71f95df

Browse files
author
Shannon Anahata
committed
fixing lint errors
1 parent 65ff1df commit 71f95df

File tree

2 files changed

+98
-123
lines changed

2 files changed

+98
-123
lines changed

src/components/docPage/index.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
getCurrentPlatform,
88
nodeForPath,
99
} from 'sentry-docs/docTree';
10-
import {getCurrentGuide, getCurrentPlatform, nodeForPath} from 'sentry-docs/docTree';
1110
import Markdown from 'sentry-docs/icons/Markdown';
1211
import {serverContext} from 'sentry-docs/serverContext';
1312
import {FrontMatter} from 'sentry-docs/types';
@@ -112,17 +111,6 @@ export function DocPage({
112111
<div className="mb-4">
113112
<Banner />
114113
</div>
115-
<div className="overflow-hidden">
116-
{leafNode && <Breadcrumbs leafNode={leafNode} />}{' '}
117-
<Link
118-
rel="nofollow"
119-
className="float-right"
120-
href={`/${pathname}.md`}
121-
title="Markdown version of this page"
122-
>
123-
<Markdown className="flex p-0 flex-wrap" width={24} height={24} />
124-
</Link>
125-
</div>
126114
<div>
127115
<hgroup>
128116
<h1>{frontMatter.title}</h1>

src/mdx.ts

Lines changed: 98 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import yaml from 'js-yaml';
55
import {bundleMDX} from 'mdx-bundler';
66
import {access, opendir, readFile} from 'node:fs/promises';
77
import path from 'node:path';
8-
import {limitFunction} from 'p-limit';
8+
import pLimit from 'p-limit';
99
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
1010
import rehypePresetMinify from 'rehype-preset-minify';
1111
import rehypePrismDiff from 'rehype-prism-diff';
@@ -145,29 +145,27 @@ export async function getDevDocsFrontMatterUncached(): Promise<FrontMatter[]> {
145145
const folder = 'develop-docs';
146146
const docsPath = path.join(root, folder);
147147
const files = await getAllFilesRecursively(docsPath);
148+
const limit = pLimit(FILE_CONCURRENCY_LIMIT);
148149
const frontMatters = (
149150
await Promise.all(
150-
files.map(
151-
limitFunction(
152-
async file => {
153-
const fileName = file.slice(docsPath.length + 1);
154-
if (path.extname(fileName) !== '.md' && path.extname(fileName) !== '.mdx') {
155-
return undefined;
156-
}
151+
files.map(file =>
152+
limit(async () => {
153+
const fileName = file.slice(docsPath.length + 1);
154+
if (path.extname(fileName) !== '.md' && path.extname(fileName) !== '.mdx') {
155+
return undefined;
156+
}
157157

158-
const source = await readFile(file, 'utf8');
159-
const {data: frontmatter} = matter(source);
160-
return {
161-
...(frontmatter as FrontMatter),
162-
slug: fileName.replace(/\/index.mdx?$/, '').replace(/\.mdx?$/, ''),
163-
sourcePath: path.join(folder, fileName),
164-
};
165-
},
166-
{concurrency: FILE_CONCURRENCY_LIMIT}
167-
)
158+
const source = await readFile(file, 'utf8');
159+
const {data: frontmatter} = matter(source);
160+
return {
161+
...(frontmatter as FrontMatter),
162+
slug: fileName.replace(/\/index.mdx?$/, '').replace(/\.mdx?$/, ''),
163+
sourcePath: path.join(folder, fileName),
164+
};
165+
})
168166
)
169167
)
170-
).filter(isNotNil);
168+
).filter(isNotNil) as FrontMatter[];
171169
return frontMatters;
172170
}
173171

@@ -184,30 +182,28 @@ async function getAllFilesFrontMatter(): Promise<FrontMatter[]> {
184182
const docsPath = path.join(root, 'docs');
185183
const files = await getAllFilesRecursively(docsPath);
186184
const allFrontMatter: FrontMatter[] = [];
185+
const limit = pLimit(FILE_CONCURRENCY_LIMIT);
187186

188187
await Promise.all(
189-
files.map(
190-
limitFunction(
191-
async file => {
192-
const fileName = file.slice(docsPath.length + 1);
193-
if (path.extname(fileName) !== '.md' && path.extname(fileName) !== '.mdx') {
194-
return;
195-
}
188+
files.map(file =>
189+
limit(async () => {
190+
const fileName = file.slice(docsPath.length + 1);
191+
if (path.extname(fileName) !== '.md' && path.extname(fileName) !== '.mdx') {
192+
return;
193+
}
196194

197-
if (fileName.indexOf('/common/') !== -1) {
198-
return;
199-
}
195+
if (fileName.indexOf('/common/') !== -1) {
196+
return;
197+
}
200198

201-
const source = await readFile(file, 'utf8');
202-
const {data: frontmatter} = matter(source);
203-
allFrontMatter.push({
204-
...(frontmatter as FrontMatter),
205-
slug: formatSlug(fileName),
206-
sourcePath: path.join('docs', fileName),
207-
});
208-
},
209-
{concurrency: FILE_CONCURRENCY_LIMIT}
210-
)
199+
const source = await readFile(file, 'utf8');
200+
const {data: frontmatter} = matter(source);
201+
allFrontMatter.push({
202+
...(frontmatter as FrontMatter),
203+
slug: formatSlug(fileName),
204+
sourcePath: path.join('docs', fileName),
205+
});
206+
})
211207
)
212208
);
213209

@@ -244,50 +240,44 @@ async function getAllFilesFrontMatter(): Promise<FrontMatter[]> {
244240
);
245241

246242
const commonFiles = await Promise.all(
247-
commonFileNames.map(
248-
limitFunction(
249-
async commonFileName => {
250-
const source = await readFile(commonFileName, 'utf8');
251-
const {data: frontmatter} = matter(source);
252-
return {commonFileName, frontmatter: frontmatter as FrontMatter};
253-
},
254-
{concurrency: FILE_CONCURRENCY_LIMIT}
255-
)
243+
commonFileNames.map(commonFileName =>
244+
limit(async () => {
245+
const source = await readFile(commonFileName, 'utf8');
246+
const {data: frontmatter} = matter(source);
247+
return {commonFileName, frontmatter: frontmatter as FrontMatter};
248+
})
256249
)
257250
);
258251

259252
await Promise.all(
260-
commonFiles.map(
261-
limitFunction(
262-
async f => {
263-
if (!isSupported(f.frontmatter, platformName)) {
264-
return;
265-
}
253+
commonFiles.map(f =>
254+
limit(async () => {
255+
if (!isSupported(f.frontmatter, platformName)) {
256+
return;
257+
}
266258

267-
const subpath = f.commonFileName.slice(commonPath.length + 1);
268-
const slug = f.commonFileName
269-
.slice(docsPath.length + 1)
270-
.replace(/\/common\//, '/');
271-
const noFrontMatter = (
272-
await Promise.allSettled([
273-
access(path.join(docsPath, slug)),
274-
access(path.join(docsPath, slug.replace('/index.mdx', '.mdx'))),
275-
])
276-
).every(r => r.status === 'rejected');
277-
if (noFrontMatter) {
278-
let frontmatter = f.frontmatter;
279-
if (subpath === 'index.mdx') {
280-
frontmatter = {...frontmatter, ...platformFrontmatter};
281-
}
282-
allFrontMatter.push({
283-
...frontmatter,
284-
slug: formatSlug(slug),
285-
sourcePath: 'docs/' + f.commonFileName.slice(docsPath.length + 1),
286-
});
259+
const subpath = f.commonFileName.slice(commonPath.length + 1);
260+
const slug = f.commonFileName
261+
.slice(docsPath.length + 1)
262+
.replace(/\/common\//, '/');
263+
const noFrontMatter = (
264+
await Promise.allSettled([
265+
access(path.join(docsPath, slug)),
266+
access(path.join(docsPath, slug.replace('/index.mdx', '.mdx'))),
267+
])
268+
).every(r => r.status === 'rejected');
269+
if (noFrontMatter) {
270+
let frontmatter = f.frontmatter;
271+
if (subpath === 'index.mdx') {
272+
frontmatter = {...frontmatter, ...platformFrontmatter};
287273
}
288-
},
289-
{concurrency: FILE_CONCURRENCY_LIMIT}
290-
)
274+
allFrontMatter.push({
275+
...frontmatter,
276+
slug: formatSlug(slug),
277+
sourcePath: 'docs/' + f.commonFileName.slice(docsPath.length + 1),
278+
});
279+
}
280+
})
291281
)
292282
);
293283

@@ -317,40 +307,37 @@ async function getAllFilesFrontMatter(): Promise<FrontMatter[]> {
317307
}
318308

319309
await Promise.all(
320-
commonFiles.map(
321-
limitFunction(
322-
async f => {
323-
if (!isSupported(f.frontmatter, platformName, guideName)) {
324-
return;
325-
}
326-
327-
const subpath = f.commonFileName.slice(commonPath.length + 1);
328-
const slug = path.join(
329-
'platforms',
330-
platformName,
331-
'guides',
332-
guideName,
333-
subpath
334-
);
335-
try {
336-
await access(path.join(docsPath, slug));
337-
return;
338-
} catch {
339-
// pass
340-
}
341-
342-
let frontmatter = f.frontmatter;
343-
if (subpath === 'index.mdx') {
344-
frontmatter = {...frontmatter, ...guideFrontmatter};
345-
}
346-
allFrontMatter.push({
347-
...frontmatter,
348-
slug: formatSlug(slug),
349-
sourcePath: 'docs/' + f.commonFileName.slice(docsPath.length + 1),
350-
});
351-
},
352-
{concurrency: FILE_CONCURRENCY_LIMIT}
353-
)
310+
commonFiles.map(f =>
311+
limit(async () => {
312+
if (!isSupported(f.frontmatter, platformName, guideName)) {
313+
return;
314+
}
315+
316+
const subpath = f.commonFileName.slice(commonPath.length + 1);
317+
const slug = path.join(
318+
'platforms',
319+
platformName,
320+
'guides',
321+
guideName,
322+
subpath
323+
);
324+
try {
325+
await access(path.join(docsPath, slug));
326+
return;
327+
} catch {
328+
// pass
329+
}
330+
331+
let frontmatter = f.frontmatter;
332+
if (subpath === 'index.mdx') {
333+
frontmatter = {...frontmatter, ...guideFrontmatter};
334+
}
335+
allFrontMatter.push({
336+
...frontmatter,
337+
slug: formatSlug(slug),
338+
sourcePath: 'docs/' + f.commonFileName.slice(docsPath.length + 1),
339+
});
340+
})
354341
)
355342
);
356343
}

0 commit comments

Comments
 (0)