-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
historic docs v2 #1770
historic docs v2 #1770
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const fs = require('fs'); | ||
|
||
version_files = [ | ||
"versions.json", | ||
"versioned_docs", | ||
"versioned_sidebars" | ||
] | ||
|
||
for (let f of version_files) { | ||
fs.rmSync(f, { recursive: true, force: true }) | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
const proc = require('child_process') | ||
const fs = require('fs'); | ||
const semver = require('semver') | ||
|
||
|
||
// const | ||
const REPO_DIR = ".dlt-repo" | ||
const REPO_DOCS_DIR = REPO_DIR + "/docs/website" | ||
const REPO_URL = "https://github.com/dlt-hub/dlt.git" | ||
const VERSIONED_DOCS_FOLDER = "versioned_docs" | ||
const VERSIONED_SIDEBARS_FOLDER = "versioned_sidebars" | ||
const ENV_FILE = '.env' | ||
|
||
// no doc versions below this version will be deployed | ||
const MINIMUM_SEMVER_VERSION = "0.5.0" | ||
|
||
// clear old repo version | ||
fs.rmSync(REPO_DIR, { recursive: true, force: true }) | ||
|
||
// checkout fresh | ||
console.log("Checking out dlt repo") | ||
proc.execSync(`git clone ${REPO_URL} ${REPO_DIR}`) | ||
|
||
// find tags | ||
console.log("Discovering versions") | ||
const tags = proc.execSync(`cd ${REPO_DIR} && git tag`).toString().trim().split("\n"); | ||
console.log(`Found ${tags.length} tags`) | ||
|
||
// parse and filter invalid tags | ||
let versions = tags.map(v => semver.valid(v)).filter(v => v != null) | ||
|
||
// remove all tags below the min version and sort | ||
min_version = semver.valid(MINIMUM_SEMVER_VERSION) | ||
versions = semver.rsort(versions.filter(v => semver.gt(v, min_version))) | ||
|
||
// remove prelease versions | ||
versions.filter(v => semver.prerelease(v) == null) | ||
|
||
console.log(`Found ${versions.length} elligible versions`) | ||
if (versions.length < 2) { | ||
console.error("Sanity check failed, not enough elligble version tags found") | ||
process.exit(1) | ||
} | ||
|
||
// write last version into env file | ||
const envFileContent = `DOCUSAURUS_DLT_VERSION=${versions[0]}`; | ||
fs.writeFileSync(ENV_FILE, envFileContent, 'utf8'); | ||
|
||
// go through the versions and find all newest versions of any major version | ||
// the newest version is replace by the master branch here so the master head | ||
// always is the "current" doc | ||
const selectedVersions = ["master"]; | ||
let lastVersion = versions[0]; | ||
for (let ver of versions) { | ||
if ( semver.major(ver) != semver.major(lastVersion)) { | ||
selectedVersions.push(ver) | ||
} | ||
lastVersion = ver; | ||
} | ||
|
||
console.log(`Will create docs versions for ${selectedVersions}`) | ||
|
||
// create folders | ||
fs.rmSync(VERSIONED_DOCS_FOLDER, { recursive: true, force: true }) | ||
fs.rmSync(VERSIONED_SIDEBARS_FOLDER, { recursive: true, force: true }) | ||
fs.rmSync("versions.json", { force: true }) | ||
|
||
fs.mkdirSync(VERSIONED_DOCS_FOLDER); | ||
fs.mkdirSync(VERSIONED_SIDEBARS_FOLDER); | ||
|
||
// check that checked out repo is on devel | ||
console.log("Checking branch") | ||
const branch = proc.execSync(`cd ${REPO_DIR} && git rev-parse --abbrev-ref HEAD`).toString().trim() | ||
|
||
// sanity check | ||
if (branch != "devel") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I do not understand this part. We should not use the REPO_DIR to build the current (development) docs. What IMO we should do:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is how it works, this line only is a sanity check wether the repo could be checked out properly. the devel branch of the checked out repo never actually is built, check further down, it only ever builds stuff collected in the versions. |
||
console.error("Could not check out devel branch") | ||
process.exit(1) | ||
} | ||
|
||
selectedVersions.reverse() | ||
for (const version of selectedVersions) { | ||
|
||
// checkout verison and verify we have the right tag | ||
console.log(`Generating version ${version}, switching to tag:`) | ||
proc.execSync(`cd ${REPO_DIR} && git checkout ${version}`) | ||
|
||
// const tag = proc.execSync(`cd ${REPO_DIR} && git describe --exact-match --tags`).toString().trim() | ||
// if (tag != version) { | ||
// console.error(`Could not checkout version ${version}`) | ||
// process.exit(1) | ||
// } | ||
|
||
// build doc version, we also run preprocessing and markdown gen for each doc version | ||
console.log(`Building docs...`) | ||
proc.execSync(`cd ${REPO_DOCS_DIR} && npm run preprocess-docs && PYTHONPATH=. pydoc-markdown`) | ||
|
||
console.log(`Snapshotting version...`) | ||
proc.execSync(`cd ${REPO_DOCS_DIR} && npm run docusaurus docs:version ${version}`) | ||
|
||
console.log(`Moving snapshot`) | ||
fs.cpSync(REPO_DOCS_DIR+"/"+VERSIONED_DOCS_FOLDER, VERSIONED_DOCS_FOLDER, {recursive: true}) | ||
fs.cpSync(REPO_DOCS_DIR+"/"+VERSIONED_SIDEBARS_FOLDER, VERSIONED_SIDEBARS_FOLDER, {recursive: true}) | ||
|
||
} | ||
|
||
fs.cpSync(REPO_DOCS_DIR+"/versions.json", "versions.json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add
0.5.4 (latest)
to the top tag?