Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export const listFirstWordCapitalization = {
const firstWord = content.trim().split(' ')[0]

// Liquid is considered a text node but we don't want to capitalize it
if (/^[{%|{{]/.test(content)) return
if (firstWord.startsWith('[{%') || firstWord.startsWith('{%') || firstWord.startsWith('{{'))
return
// If the first letter is capitalized, it's not an error
if (/[A-Z]/.test(firstWord[0])) return
// There are items that start with a number or words that contain numbers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ describe(listFirstWordCapitalization.names.join(' - '), () => {
"- '[AUTOTITLE](/billing/managing-billing-for-github-marketplace-apps)'",
'- [Viewing your sponsors and sponsorships](/sponsors/receiving-sponsorships-through-github-sponsors/viewing-your-sponsors-and-sponsorships)',
'- macOS',
'- [{% data variables.actions.test %}](/apple/test)',
'- {{ foo }} for example',
'- {% data variables.product.prodname_dotcom_the_website %} Services Continuity and Incident Management Plan',
'- {% data variables.product.prodname_dotcom_the_website %} Services Continuity and Incident Management Plan',
'- x64',
Expand Down
10 changes: 9 additions & 1 deletion src/search/scripts/index-elasticsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ import { retryOnErrorTest } from './retry-on-error-test.js'
import { languageKeys } from '#src/languages/lib/languages.js'
import { allVersions } from '#src/versions/lib/all-versions.js'

const availableVersions = Object.fromEntries(
Object.entries(allVersions)
// GHAE is deprecated and not yet entirely deleted from all-versions
// Until so, we manually filter it out.
.filter(([version]) => version !== 'github-ae@latest')
.map(([key, value]) => [key, value]),
)

// Now you can optionally have set the ELASTICSEARCH_URL in your .env file.
dotenv.config()

Expand All @@ -38,7 +46,7 @@ dotenv.config()
// We need this later to be able to map CLI arguments to what the
// records are called when found on disk.
const shortNames = Object.fromEntries(
Object.values(allVersions).map((info) => {
Object.values(availableVersions).map((info) => {
const shortName = info.hasNumberedReleases
? info.miscBaseName + info.currentRelease
: info.miscBaseName
Expand Down
13 changes: 10 additions & 3 deletions src/search/scripts/sync-search-indices.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@ import { languageKeys } from '#src/languages/lib/languages.js'
import { allVersions } from '#src/versions/lib/all-versions.js'
import searchSync from './sync.js'

const availableVersions = Object.fromEntries(
Object.entries(allVersions)
// GHAE is deprecated and not yet entirely deleted from all-versions
// Until so, we manually filter it out.
.filter(([version]) => version !== 'github-ae@latest')
.map(([key, value]) => [key, value]),
)
const shortNames = Object.fromEntries(
Object.values(allVersions).map((info) => {
Object.values(availableVersions).map((info) => {
const shortName = info.hasNumberedReleases
? info.miscBaseName + info.currentRelease
: info.miscBaseName
return [shortName, info]
}),
)

const allVersionKeys = [...Object.keys(shortNames), ...Object.keys(allVersions)]
const allVersionKeys = [...Object.keys(shortNames), ...Object.keys(availableVersions)]

program
.description('Creates search records by scraping')
Expand Down Expand Up @@ -133,9 +140,9 @@ async function main(opts, args) {
const options = {
language,
notLanguage,
version: indexVersion,
outDirectory,
config,
versionsToBuild: indexVersion ? [indexVersion] : Object.keys(availableVersions),
}
await searchSync(options)
}
9 changes: 2 additions & 7 deletions src/search/scripts/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { writeIndexRecords } from './search-index-records.js'
// e.g. `github-docs-dotcom-en.json` and `github-docs-2.14-ja.json`
export default async function syncSearchIndexes({
language,
version,
notLanguage,
outDirectory,
versionsToBuild,
config = {},
}) {
const t0 = new Date()
Expand All @@ -24,14 +24,9 @@ export default async function syncSearchIndexes({
notLanguage ? notLanguage !== lang : language ? language === lang : true,
)

// build indices for a specific version if provided; otherwise build indices for all versions
const versionsToBuild = Object.keys(allVersions).filter((ver) =>
version ? version === ver : true,
)

console.log(
`Building indices for ${chalk.yellow(language || 'all languages')} and ${chalk.yellow(
version || 'all versions',
versionsToBuild.length === 1 ? versionsToBuild[0] : 'all versions',
)}.\n`,
)

Expand Down