Skip to content

Commit

Permalink
Remove support versions: * (#40548)
Browse files Browse the repository at this point in the history
  • Loading branch information
gracepark authored Aug 11, 2023
1 parent ceaeec8 commit 7403206
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
---
title: About versions of GitHub Docs
intro: 'You can read documentation that reflects the {% data variables.product.company_short %} product you''re currently using.'
versions: '*'
versions:
fpt: '*'
ghes: '*'
ghae: '*'
ghec: '*'
shortTitle: Docs versions
---

Expand Down
6 changes: 5 additions & 1 deletion content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ redirect_from:
- /github/enforcing-best-practices-with-github-policies/sharing
- /early-access/github/enforcing-best-practices-with-github-policies/syntax
- /github/enforcing-best-practices-with-github-policies/syntax
versions: '*'
versions:
fpt: '*'
ghes: '*'
ghae: '*'
ghec: '*'
children:
- search
- get-started
Expand Down
6 changes: 4 additions & 2 deletions lib/get-applicable-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ function getApplicableVersions(versionsObj, filepath, opts = {}) {
throw new Error(`No \`versions\` frontmatter found in ${filepath}`)
}

// all versions are applicable!
// Catch an old frontmatter value that was used to indicate an article was available in all versions.
if (versionsObj === '*') {
return allVersionKeys
throw new Error(
`${filepath} contains the invalid versions frontmatter: *. Please explicitly list out all the versions that apply to this article.`,
)
}

if (!featureData) {
Expand Down
4 changes: 2 additions & 2 deletions script/update-tocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// [start-readme]
//
// This script creates or updates an index.md file for a given directory.
// It will add `children` frontmatter in alphabetical order and create versions: '*'.
// It will add `children` frontmatter in alphabetical order and create versions: { fpt: '*', ghes: '*', ghae: '*', ghec: '*' }.
// It also prints a helpful message to update those values manually if needed.
//
// [end-readme]
Expand Down Expand Up @@ -52,7 +52,7 @@ function updateOrCreateToc(directory) {
content = ''
data = {
title: sentenceCase(path.basename(directory)), // fake the title of the index.md from the directory name
versions: '*', // default to all versions
versions: { fpt: '*', ghes: '*', ghae: '*', ghec: '*' }, // default to all versions
}
}

Expand Down
6 changes: 5 additions & 1 deletion tests/fixtures/article-with-redirect-from-string.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
---
title: Article with redirect_from string
versions: '*'
versions:
fpt: '*'
ghes: '*'
ghae: '*'
ghec: '*'
redirect_from: /redirect-string
---
6 changes: 5 additions & 1 deletion tests/fixtures/content/early-access/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
---
title: Early Access documentation
hidden: true
versions: '*'
versions:
fpt: '*'
ghes: '*'
ghae: '*'
ghec: '*'
children:
- /secrets
---
Expand Down
6 changes: 5 additions & 1 deletion tests/fixtures/content/early-access/secrets/deeper/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
title: Deeper secrets
versions: '*'
versions:
fpt: '*'
ghes: '*'
ghae: '*'
ghec: '*'
hidden: true
children:
- /mariana-trench
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
title: Mariana Trench
versions: '*'
versions:
fpt: '*'
ghes: '*'
ghae: '*'
ghec: '*'
hidden: true
---

Expand Down
6 changes: 5 additions & 1 deletion tests/fixtures/content/early-access/secrets/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
title: GitHub Secrets
versions: '*'
versions:
fpt: '*'
ghes: '*'
ghae: '*'
ghec: '*'
hidden: true
children:
- /early-days
Expand Down
6 changes: 5 additions & 1 deletion tests/fixtures/content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ featuredLinks:
- /actions/category/map-topic
redirect_from:
- /olden-days
versions: '*'
versions:
fpt: '*'
ghes: '*'
ghae: '*'
ghec: '*'
children:
# The list of childen in the fixtures has to be the same names
# as we use in the real content. It can have fewer but can't include
Expand Down
6 changes: 5 additions & 1 deletion tests/fixtures/liquid-tags/bad-data-variable.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
title: Sample page
versions: '*'
versions:
fpt: '*'
ghes: '*'
ghae: '*'
ghec: '*'
---

{% data foo.bar.tipu %}
6 changes: 5 additions & 1 deletion tests/fixtures/liquid-tags/good-data-variable.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
title: Good sample page
versions: '*'
versions:
fpt: '*'
ghes: '*'
ghae: '*'
ghec: '*'
---

{% data variables.stuff.foo %}
16 changes: 12 additions & 4 deletions tests/unit/get-applicable-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,18 @@ describe('Versions frontmatter', () => {
})

describe('general cases', () => {
test('simply a wildcard', () => {
const applicableVersions = getApplicableVersions('*')
expect(applicableVersions.length).toBe(Object.keys(allVersions).length)
expect(Object.keys(allVersions).every((v) => applicableVersions.includes(v)))
test('wildcard * is no longer used', () => {
// docs engineering 3110
expect.assertions(2)
try {
getApplicableVersions('*')
} catch (e) {
expect(e).toBeInstanceOf(Error)
expect(e).toHaveProperty(
'message',
'undefined contains the invalid versions frontmatter: *. Please explicitly list out all the versions that apply to this article.',
)
}
})
test("using 'features'", () => {
const possibleFeatures = fs
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ describe('Page class', () => {
basePath: path.join(__dirname, '../../content'),
languageCode: 'en',
})
expect(page.versions).toBe('*')
expect(page.versions).toEqual({ fpt: '*', ghae: '*', ghec: '*', ghes: '*' })
})

test('enterprise admin index page', async () => {
Expand Down

0 comments on commit 7403206

Please sign in to comment.