mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
Update readme and link to guides
This commit is contained in:
@ -53,14 +53,14 @@ const samples = [
|
||||
{
|
||||
description: 'LSP Multi Root Server Sample',
|
||||
path: 'lsp-multi-server-sample',
|
||||
guide: null,
|
||||
guide: 'https://github.com/Microsoft/vscode/wiki/Extension-Authoring:-Adopting-Multi-Root-Workspace-APIs#language-client--language-server',
|
||||
apis: [],
|
||||
contributions: []
|
||||
},
|
||||
{
|
||||
description: 'LSP Sample',
|
||||
path: 'lsp-sample',
|
||||
guide: null,
|
||||
guide: '/api/language-extensions/smart-editing-lsp-guide',
|
||||
apis: [],
|
||||
contributions: []
|
||||
},
|
||||
|
||||
@ -12,35 +12,39 @@ const TABLE_END = `
|
||||
<!-- SAMPLES_END -->
|
||||
`
|
||||
|
||||
const getTableRow = (sample) => {
|
||||
const descriptionCell = `[${sample.description}](${sample.path})`
|
||||
const guideCell = sample.guide ? `[${sample.guide}](https://vscode-ext-docs.azurewebsites.net${sample.guide})` : 'N/A'
|
||||
const getTableRow = sample => {
|
||||
const descriptionCell = `[${sample.description}](${sample.path})`
|
||||
let guideCell
|
||||
if (!sample.guide) {
|
||||
guideCell = 'N/A'
|
||||
} else if (sample.guide && sample.guide.startsWith('http')) {
|
||||
guideCell = sample.guide
|
||||
} else {
|
||||
guideCell = `[${sample.guide}](https://vscode-ext-docs.azurewebsites.net${sample.guide})`
|
||||
}
|
||||
|
||||
const apis = sample.apis.map(api => {
|
||||
return `[${api}](https://vscode-ext-docs.azurewebsites.net/api/references/vscode-api#${api})`
|
||||
})
|
||||
const contributions = sample.contributions.map(c => {
|
||||
return `[${c}](https://vscode-ext-docs.azurewebsites.net/api/references/contribution-points#${c})`
|
||||
})
|
||||
const apiAndContributionCell = apis.concat(contributions).join('<br>')
|
||||
const apis = sample.apis.map(api => {
|
||||
return `[${api}](https://vscode-ext-docs.azurewebsites.net/api/references/vscode-api#${api})`
|
||||
})
|
||||
const contributions = sample.contributions.map(c => {
|
||||
return `[${c}](https://vscode-ext-docs.azurewebsites.net/api/references/contribution-points#${c})`
|
||||
})
|
||||
const apiAndContributionCell = apis.concat(contributions).join('<br>')
|
||||
|
||||
return `| ${descriptionCell} | ${guideCell} | ${apiAndContributionCell} |`
|
||||
return `| ${descriptionCell} | ${guideCell} | ${apiAndContributionCell} |`
|
||||
}
|
||||
|
||||
const getSamplesTable = (samples) => {
|
||||
const samplesMd = samples
|
||||
.map(s => getTableRow(s))
|
||||
.join('\n')
|
||||
const getSamplesTable = samples => {
|
||||
const samplesMd = samples.map(s => getTableRow(s)).join('\n')
|
||||
|
||||
return `
|
||||
return `
|
||||
${TABLE_HEAD.trim()}
|
||||
${samplesMd}
|
||||
${TABLE_END.trim()}
|
||||
`
|
||||
|
||||
}
|
||||
|
||||
const readme = fs.readFileSync('README.md', 'utf-8')
|
||||
const newReadme = readme.replace(/<!-- SAMPLES_BEGIN -->(.|\n)*<!-- SAMPLES_END -->/gm, getSamplesTable(SAMPLES))
|
||||
|
||||
fs.writeFileSync('README.md', newReadme)
|
||||
fs.writeFileSync('README.md', newReadme)
|
||||
|
||||
Reference in New Issue
Block a user