Skip to content

Commit 0ae3d35

Browse files
authored
Merge pull request github#16143 from github/hidden-docs-alt
Early-access docs V2
2 parents 11d8e41 + ca39999 commit 0ae3d35

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+876
-356
lines changed

.env.example

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
ALGOLIA_API_KEY=
22
ALGOLIA_APPLICATION_ID=
33
ALLOW_TRANSLATION_COMMITS=
4-
EARLY_ACCESS_HOSTNAME=
5-
EARLY_ACCESS_SHARED_SECRET=
6-
GITHUB_TOKEN=

.github/workflows/test.yml

+13-10
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
with:
2828
cancel_others: 'false'
2929
github_token: ${{ github.token }}
30-
paths: '[".github/workflows/test.yml",".node-version", ".npmrc", "app.json", "content/**", "data/**","lib/**", "Dockerfile", "feature-flags.json", "Gemfile", "Gemfile.lock", "middleware/**", "node_modules/**","package.json", "package-lock.json", "server.js", "tests/**", "translations/**", "Procfile", "webpack.config.js"]'
30+
paths: '[".github/workflows/test.yml", ".node-version", ".npmrc", "app.json", "content/**", "data/**","lib/**", "Dockerfile", "feature-flags.json", "Gemfile", "Gemfile.lock", "middleware/**", "node_modules/**","package.json", "package-lock.json", "server.js", "tests/**", "translations/**", "Procfile", "webpack.config.js"]'
3131

3232
test:
3333
needs: see_if_should_skip
@@ -44,6 +44,9 @@ jobs:
4444
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
4545
name: Check out repo
4646
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
47+
with:
48+
# Enables cloning the Early Access repo later with the relevant PAT
49+
persist-credentials: 'false'
4750

4851
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
4952
name: Setup node
@@ -70,19 +73,19 @@ jobs:
7073
name: Install dependencies
7174
run: npm ci
7275

73-
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
74-
name: Run build script
76+
- name: Clone early access
77+
if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' && github.repository == 'github/docs-internal' }}
78+
run: npm run heroku-postbuild
79+
env:
80+
DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }}
81+
GIT_BRANCH: ${{ github.ref }}
82+
83+
- name: Run build script
84+
if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' && github.repository != 'github/docs-internal' }}
7585
run: npm run build
7686

7787
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
7888
name: Run tests
7989
run: npx jest tests/${{ matrix.test-group }}/
8090
env:
8191
NODE_OPTIONS: '--max_old_space_size=4096'
82-
83-
- name: Send Slack notification if workflow fails
84-
uses: rtCamp/action-slack-notify@e17352feaf9aee300bf0ebc1dfbf467d80438815
85-
if: failure() && github.ref == 'early-access'
86-
env:
87-
SLACK_WEBHOOK: ${{ secrets.DOCS_ALERTS_SLACK_WEBHOOK }}
88-
SLACK_MESSAGE: 'Tests are failing on the `early-access` branch.'

.gitignore

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
.algolia-cache
22
.DS_Store
33
.env
4-
node_modules
4+
/node_modules/
55
npm-debug.log
6-
coverage
6+
coverage/
77
.linkinator
8-
broken_links.md
8+
/assets/images/early-access
9+
/content/early-access
10+
/data/early-access
911
dist
12+
13+
# blc: broken link checker
14+
blc_output.log
15+
blc_output_internal.log
16+
/dist/
17+
broken_links.md

content/rest/overview/api-previews.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: API previews
33
intro: You can use API previews to try out new features and provide feedback before these features become official.
44
redirect_from:
5-
- /early-access/
65
- /v3/previews
76
versions:
87
free-pro-team: '*'
@@ -60,7 +59,7 @@ Create, list, update, and delete environments for pre-receive hooks.
6059
{% if enterpriseServerVersions contains currentVersion and currentVersion ver_lt "[email protected]" %}
6160
### Integrations
6261

63-
Manage [integrations](/early-access/integrations/) through the API.
62+
Manage [integrations](/v3/integrations) through the API.
6463

6564
**Custom media type:** `machine-man-preview`
6665
**Announced:** [2016-09-14](https://developer.github.com/changes/2016-09-14-Integrations-Early-Access/)

crowdin.yml

+8-6
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@ files:
33
translation: /translations/%locale%/%original_path%/%original_file_name%
44
ignore:
55
- '/content/README.md'
6+
- '/content/early-access'
67
- source: /data/**/*.yml
78
translation: /translations/%locale%/%original_path%/%original_file_name%
89
- source: /data/**/*.md
910
translation: /translations/%locale%/%original_path%/%original_file_name%
1011
ignore:
11-
- 'data/README.md'
12-
- 'data/reusables/README.md'
13-
- 'data/variables/product.yml'
14-
- 'data/variables/README.md'
15-
- 'data/graphql'
16-
- 'data/products.yml'
12+
- '/data/README.md'
13+
- '/data/reusables/README.md'
14+
- '/data/variables/product.yml'
15+
- '/data/variables/README.md'
16+
- '/data/early-access'
17+
- '/data/graphql'
18+
- '/data/products.yml'
1719

1820
# These end up as env vars used by the GitHub Actions workflow
1921
project_id_env: CROWDIN_PROJECT_ID

includes/article.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ <h3 id="in-this-article" class="f5 mb-2"><a class="link-gray-dark" href="#in-thi
6767

6868
<div class="d-block border-top border-gray-light mt-4 markdown-body">
6969
{% include helpfulness %}
70-
{% include contribution %}
70+
{% unless page.hidden %}{% include contribution %}{% endunless %}
7171
</div>
7272
</article>
7373
</main>

includes/breadcrumbs.html

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<nav class="breadcrumbs f5" aria-label="Breadcrumb">
22
{% for breadcrumb in breadcrumbs %}
3+
{% if page.hidden %}
4+
<span class="d-inline-block">{{breadcrumb[1].title}}</span>
5+
{% else %}
36
<a title="{{ breadcrumb[0]}}: {{breadcrumb[1].title}}" href="/{{currentLanguage}}{{breadcrumb[1].href}}" class="d-inline-block {% if breadcrumb[1].href == currentPathWithoutLanguage %}text-gray-light{% endif %}">
47
{{breadcrumb[1].title}}</a>
8+
{% endif %}
59
{% endfor %}
610
</nav>

includes/header.html

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<div class="border-bottom border-gray-light no-print">
2+
{% unless error == '404' %}
23
{% include header-notification %}
4+
{% endunless %}
35

46
<header class="container-xl px-3 px-md-6 pt-3 pb-2 position-relative d-flex flex-justify-between width-full {% if error == '404' %} d-md-none {% endif %}">
57

includes/sidebar-specific-product.html

+2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
{% assign product = siteTree[currentLanguage][currentVersion].products[currentProduct] %}
1010
{% include all-products-link %}
1111
<li title="{{product.title}}" class="sidebar-product mb-2">
12+
{% unless page.hidden %}
1213
<a href="/{{currentLanguage}}{{product.href}}" class="pl-4 pr-5 pb-1 f4">{{ product.title }}</a>
14+
{% endunless %}
1315
</li>
1416
<ul class="sidebar-categories list-style-none">
1517
{% for category in product.categories %}

lib/algolia/find-indexable-pages.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ const loadPages = require('../pages')
33
module.exports = async function findIndexablePages () {
44
const allPages = await loadPages()
55
const indexablePages = allPages
6-
// exclude pages that are part of WIP products
7-
.filter(page => !page.parentProduct || !page.parentProduct.wip)
6+
// exclude hidden pages
7+
.filter(page => !page.hidden)
8+
// exclude pages that are part of WIP or hidden products
9+
.filter(page => !page.parentProduct || !page.parentProduct.wip || page.parentProduct.hidden)
810
// exclude index homepages
911
.filter(page => !page.relativePath.endsWith('index.md'))
1012

lib/all-products.js

+22-3
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,32 @@ const productsYml = yaml.load(fs.readFileSync(productsFile, 'utf8'))
1414
const sortedProductIds = productsYml.productsInOrder
1515

1616
const contentProductIds = fs.readdirSync(contentDir, { withFileTypes: true })
17+
.map(entry => {
18+
// `fs.readdir` provides file entries based on `fs.lstat`, which doesn't
19+
// resolve symbolic links to their target file/directory. We need to take
20+
// an extra step here to resolve the Early Access symlinked directory.
21+
const { name } = entry
22+
if (entry.isSymbolicLink()) {
23+
entry = fs.statSync(path.join(contentDir, entry.name))
24+
entry.name = name
25+
}
26+
return entry
27+
})
1728
.filter(entry => entry.isDirectory())
1829
.map(entry => entry.name)
1930

20-
assert(difference(sortedProductIds, contentProductIds).length === 0)
21-
assert(difference(contentProductIds, sortedProductIds).length === 0)
31+
// require the content/<subdir> list to match the list in data/products.yml,
32+
// with the exception of content/early-access, which lives in a separate private repo
33+
const publicContentProductIds = contentProductIds.filter(id => id !== 'early-access')
34+
assert(difference(sortedProductIds, publicContentProductIds).length === 0)
35+
assert(difference(publicContentProductIds, sortedProductIds).length === 0)
2236

2337
const internalProducts = {}
2438

39+
// add optional early access content dir to sorted products list if present
40+
const earlyAccessId = contentProductIds.find(id => id === 'early-access')
41+
if (earlyAccessId) sortedProductIds.push(earlyAccessId)
42+
2543
sortedProductIds.forEach(productId => {
2644
const relPath = productId
2745
const dir = slash(path.join('content', relPath))
@@ -36,7 +54,8 @@ sortedProductIds.forEach(productId => {
3654
href,
3755
dir,
3856
toc,
39-
wip: data.wip || false
57+
wip: data.wip || false,
58+
hidden: data.hidden || false
4059
}
4160

4261
internalProducts[productId].versions = applicableVersions

lib/fetch-early-access-paths.js

-33
This file was deleted.

lib/frontmatter.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@ const schema = {
3838
mapTopic: {
3939
type: 'boolean'
4040
},
41-
// The `hidden` frontmatter property is no longer used, but leaving it here
42-
// with an enum of `[false]` will help us catch any possible regressions.
41+
// allow hidden articles under `early-access`
4342
hidden: {
44-
type: 'boolean',
45-
enum: [false]
43+
type: 'boolean'
4644
},
4745
layout: {
4846
type: ['string', 'boolean'],

lib/patterns.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = {
2525
searchPath: /\/search(?:\/)?(\?)/,
2626
ymd: /^\d{4}-\d{2}-\d{2}$/,
2727
hasLiquid: /[{{][{%]/,
28-
dataReference: /{% ?data\s(?:reusables|variables|ui)\..*?%}/gm,
28+
dataReference: /{% ?data\s(?:early-access\.)?(?:reusables|variables|ui)\..*?%}/gm,
2929
imagePath: /\/?assets\/images\/.*?\.(png|svg|gif|pdf|ico|jpg|jpeg)/gi,
3030
homepagePath: /^\/\w{2}$/, // /en, /ja, /cn
3131
multipleSlashes: /^\/{2,}/,

lib/warm-server.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
const statsd = require('./statsd')
2-
const fetchEarlyAccessPaths = require('./fetch-early-access-paths')
32
const loadPages = require('./pages')
43
const loadRedirects = require('./redirects/precompile')
54
const loadSiteData = require('./site-data')
65
const loadSiteTree = require('./site-tree')
76

87
// For local caching
9-
let pages, site, redirects, siteTree, earlyAccessPaths
8+
let pages, site, redirects, siteTree
109

1110
function isFullyWarmed () {
12-
return Boolean(pages && site && earlyAccessPaths && redirects && siteTree)
11+
return Boolean(pages && site && redirects && siteTree)
1312
}
1413

1514
function getWarmedCache () {
1615
return {
1716
pages,
1817
site,
1918
redirects,
20-
siteTree,
21-
earlyAccessPaths
19+
siteTree
2220
}
2321
}
2422

@@ -29,12 +27,11 @@ async function warmServer () {
2927
console.log('Priming context information...')
3028
}
3129

32-
if (!pages || !site || !earlyAccessPaths) {
30+
if (!pages || !site) {
3331
// Promise.all is used to load multiple things in parallel
34-
[pages, site, earlyAccessPaths] = await Promise.all([
32+
[pages, site] = await Promise.all([
3533
pages || loadPages(),
36-
site || loadSiteData(),
37-
earlyAccessPaths || fetchEarlyAccessPaths()
34+
site || loadSiteData()
3835
])
3936
}
4037

middleware/context.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const languages = require('../lib/languages')
22
const enterpriseServerReleases = require('../lib/enterprise-server-releases')
33
const allVersions = require('../lib/all-versions')
44
const allProducts = require('../lib/all-products')
5-
const activeProducts = Object.values(allProducts).filter(product => !product.wip)
5+
const activeProducts = Object.values(allProducts).filter(product => !product.wip && !product.hidden)
66
const { getVersionStringFromPath, getProductStringFromPath, getPathWithoutLanguage } = require('../lib/path-utils')
77
const productNames = require('../lib/product-names')
88
const warmServer = require('../lib/warm-server')
@@ -12,7 +12,7 @@ const featureFlags = Object.keys(require('../feature-flags'))
1212
// Note that additional middleware in middleware/index.js adds to this context object
1313
module.exports = async function contextualize (req, res, next) {
1414
// Ensure that we load some data only once on first request
15-
const { site, redirects, pages, siteTree, earlyAccessPaths } = await warmServer()
15+
const { site, redirects, pages, siteTree } = await warmServer()
1616
req.context = {}
1717

1818
// make feature flag environment variables accessible in layouts
@@ -33,7 +33,6 @@ module.exports = async function contextualize (req, res, next) {
3333
req.context.currentPath = req.path
3434
req.context.query = req.query
3535
req.context.languages = languages
36-
req.context.earlyAccessPaths = earlyAccessPaths
3736
req.context.productNames = productNames
3837
req.context.enterpriseServerReleases = enterpriseServerReleases
3938
req.context.enterpriseServerVersions = Object.keys(allVersions).filter(version => version.startsWith('enterprise-server@'))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module.exports = function earlyAccessContext (req, res, next) {
2+
if (process.env.NODE_ENV === 'production') {
3+
return next(404)
4+
}
5+
6+
// Get a list of all hidden pages per version
7+
const earlyAccessPageLinks = req.context.pages
8+
.filter(page => page.hidden)
9+
// Do not include early access landing page
10+
.filter(page => page.relativePath !== 'early-access/index.md')
11+
// Create Markdown links
12+
.map(page => {
13+
return page.permalinks.map(permalink => `- [${permalink.title}](${permalink.href})`)
14+
})
15+
.flat()
16+
// Get links for the current version
17+
.filter(link => link.includes(req.context.currentVersion))
18+
.sort()
19+
20+
// Add to the rendering context
21+
// This is only used in the separate EA repo on local development
22+
req.context.earlyAccessPageLinks = earlyAccessPageLinks.length
23+
? earlyAccessPageLinks.join('\n')
24+
: '_None for this version!_'
25+
26+
return next()
27+
}

0 commit comments

Comments
 (0)