-
Notifications
You must be signed in to change notification settings - Fork 21
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
Docusaurus versioning #2
Merged
Merged
Changes from 21 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
3e397bc
wip
samricotta 06cd27c
Update glossary
samricotta 130d141
review updates
samricotta 680025c
update actions
samricotta 45ef225
remove path
samricotta 8480865
wip
samricotta 8288a37
wip
samricotta c5202d1
update version plugin
samricotta d97669f
wip
samricotta 2d029e0
versioning wip
samricotta 6fc681e
review updates
samricotta fdefd62
update actions
samricotta 2d1f472
wip
samricotta 8f291cb
Update deploy-docs.yml
samricotta c7d8c0d
Update custom-version-plugin.js
samricotta 6655f98
Merge branch 'sam/docs-revamp' into sam/versioning
samricotta 1a38534
update to versioning
samricotta 2df4810
Merge branch 'sam/versioning' of github.com:cosmos/cosmos-sdk-docs in…
samricotta 32951ef
Update docusaurus.config.js
samricotta aed7321
Update deploy-docs.yml
samricotta f102be9
Merge branch 'main' into sam/versioning
samricotta 7f05aab
Update docusaurus.config.js
samricotta 1f13d71
wip 0.46
samricotta 4fcfedc
wip
samricotta 8e6deda
Update versioning to have each version file in repo
samricotta 8eae569
Update _category_.json
samricotta ba0979b
Merge branch 'main' into sam/versioning
samricotta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,9 @@ jobs: | |
with: | ||
node-version: "16.x" | ||
|
||
shell: bash | ||
- run: yarn build | ||
- name: Build 🔧 | ||
run: yarn install --frozen-lockfile | ||
run: yarn build | ||
|
||
- name: Deploy 🚀 | ||
uses: JamesIves/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// Helper function to get all files recursively from a directory | ||
function getAllFiles(dirPath, arrayOfFiles) { | ||
arrayOfFiles = arrayOfFiles || []; | ||
const files = fs.readdirSync(dirPath); | ||
|
||
files.forEach(function (file) { | ||
const filePath = path.join(dirPath, file); | ||
if (fs.statSync(filePath).isDirectory()) { | ||
arrayOfFiles = getAllFiles(filePath, arrayOfFiles); | ||
} else { | ||
arrayOfFiles.push(filePath); | ||
} | ||
}); | ||
|
||
return arrayOfFiles; | ||
} | ||
|
||
function shouldExcludeFile(version, filePath, versionConfig) { | ||
const excludedPaths = versionConfig[version]?.excludedPaths || []; | ||
return excludedPaths.some((excludedPath) => filePath.startsWith(excludedPath)); | ||
} | ||
|
||
module.exports = function (_context, _options) { | ||
return { | ||
name: 'custom-version-plugin', | ||
|
||
async loadContent() { | ||
// Read the versions.json file to get the list of versions | ||
const versionsJsonPath = path.join(_context.siteDir, 'versions.json'); | ||
const versions = JSON.parse(fs.readFileSync(versionsJsonPath, 'utf8')); | ||
|
||
// Read the version config file | ||
const versionConfigPath = path.join(_context.siteDir, 'version_config.json'); | ||
const versionConfig = JSON.parse(fs.readFileSync(versionConfigPath, 'utf8')); | ||
|
||
// Read all the files in the /docs folder | ||
const docsPath = path.join(_context.siteDir, 'docs'); | ||
const files = getAllFiles(docsPath); | ||
|
||
// Iterate through the list of versions | ||
for (const version of versions) { | ||
const versionedDocsPath = path.join(_context.siteDir, 'versioned_docs', `version-${version}`); | ||
|
||
// Check if the version directory exists | ||
if (fs.existsSync(versionedDocsPath)) { | ||
// Iterate through the list of files in the /docs folder | ||
for (const file of files) { | ||
const relativePath = path.relative(docsPath, file); | ||
const customFilePath = path.join(versionedDocsPath, relativePath); | ||
|
||
// Check if the file exists in the version directory | ||
if (!fs.existsSync(customFilePath) && !shouldExcludeFile(version, relativePath, versionConfig)) { | ||
// If the file doesn't exist and it's not excluded, copy it from the /docs folder | ||
const customFileDir = path.dirname(customFilePath); | ||
fs.mkdirSync(customFileDir, { recursive: true }); | ||
fs.copyFileSync(file, customFilePath); | ||
console.log(`Copied file from /docs to version-${version}:`, relativePath); | ||
} | ||
} | ||
|
||
// After copying all files, iterate over the versioned directory to remove excluded files | ||
const versionedFiles = getAllFiles(versionedDocsPath); | ||
for (const file of versionedFiles) { | ||
const relativePath = path.relative(versionedDocsPath, file); | ||
|
||
if (shouldExcludeFile(version, relativePath, versionConfig)) { | ||
fs.unlinkSync(file); | ||
console.log(`Removed excluded file from version-${version}:`, relativePath); | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ const config = { | |
tagline: | ||
"Cosmos SDK is the world's most popular framework for building application-specific blockchains.", | ||
url: "https://docs.cosmos.network", | ||
baseUrl: "/", | ||
baseUrl: "/cosmos-sdk-docs", | ||
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. Cool! It could be handy to have this tiny thing in a separate PR so that https://cosmos.github.io/cosmos-sdk-docs can work sooner. |
||
onBrokenLinks: "warn", | ||
onBrokenMarkdownLinks: "warn", | ||
favicon: "img/favicon.svg", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"0.45": { | ||
"excludedPaths": ["integrate/modules/slashing", "integrate/modules/nft", "integrate/building-modules/15-depinject.md", "integrate/modules/genutil", | ||
"integrate/modules/consensus", "integrate/modules/circuit", "integrate/building-apps","integrate/building-modules/autocli", "integrate/building-modules/depinject", | ||
"integrate/building-modules/testing", "integrate/building-apps", "integrate/architecture/rfc", "integrate/specs", "integrate/architecture/adr-041-in-place-store-migrations", "integrate/architecture/adr-042-group-module", | ||
"integrate/architecture/adr-043-nft-module", "integrate/architecture/adr-044-protobuf-updates-guidelines", "integrate/architecture/adr-045-check-delivertx-middlewares", | ||
"integrate/architecture/adr-046-module-params", "integrate/architecture/adr-046-module-params", "integrate/architecture/adr-047-extend-upgrade-plan", | ||
"integrate/architecture/adr-048-consensus-fees", "integrate/architecture/adr-049-state-sync-hooks", "integrate/architecture/adr-050-sign-mode-textual", | ||
"integrate/architecture/adr-050-sign-mode-textual-annex1", "integrate/architecture/adr-050-sign-mode-textual-annex2", "integrate/architecture/adr-053-go-module-refactoring","integrate/architecture/adr-054-semver-compatible-modules", | ||
"integrate/architecture/adr-055-orm", "integrate/architecture/adr-057-app-wiring", "integrate/architecture/adr-058-auto-generated-cli", "integrate/architecture/adr-059-test-scopes", | ||
"integrate/architecture/adr-060-abci-1.0", "integrate/architecture/adr-061-liquid-staking", "integrate/architecture/adr-062-collections-state-layer", | ||
"integrate/architecture/adr-062-collections-state-layer", "integrate/architecture/adr-063-core-module-api", "integrate/architecture/adr-064-abci-2.0", | ||
"integrate/architecture/adr-065-store-v2", "integrate/architecture/README"] | ||
}, | ||
"0.46": { | ||
"excludedPaths": ["integrate/modules/genutil", "integrate/building-modules/15-depinject.md","integrate/modules/consensus", "integrate/modules/circuit", "integrate/architecture/rfc", | ||
"integrate/specs", "integrate/building-apps", "integrate/building-modules/depinject", "integrate/architecture/adr-007-specialization-groups", | ||
"integrate/architecture/adr-008-dCERT-group", "integrate/architecture/adr-014-proportional-slashing", | ||
"integrate/architecture/adr-034-account-keying", "integrate/architecture/adr-041-in-place-store-migrations", "integrate/architecture/adr-042-group-module", | ||
"integrate/architecture/adr-043-nft-module", "integrate/architecture/adr-044-protobuf-updates-guidelines", "integrate/architecture/adr-045-check-delivertx-middlewares", | ||
"integrate/architecture/adr-048-consensus-fees", "integrate/architecture/adr-049-state-sync-hooks", "integrate/architecture/adr-050-sign-mode-textual", | ||
"integrate/architecture/adr-050-sign-mode-textual-annex1", "integrate/architecture/adr-050-sign-mode-textual-annex2", "integrate/architecture/adr-054-semver-compatible-modules", | ||
"integrate/architecture/adr-055-orm", "integrate/architecture/adr-057-app-wiring", "integrate/architecture/adr-058-auto-generated-cli", "integrate/architecture/adr-059-test-scopes", | ||
"integrate/architecture/adr-060-abci-1.0", "integrate/architecture/adr-061-liquid-staking", "integrate/architecture/adr-062-collections-state-layer", | ||
"integrate/architecture/adr-062-collections-state-layer", "integrate/architecture/adr-063-core-module-api", "integrate/architecture/adr-064-abci-2.0", | ||
"integrate/architecture/adr-065-store-v2", "integrate/architecture/README"] | ||
}, | ||
"0.47": { | ||
"excludedPaths": [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!-- | ||
order: false | ||
parent: | ||
order: 5 | ||
--> | ||
|
||
# IBC | ||
|
||
This repository contains reference documentation for the IBC protocol integration and concepts: | ||
|
||
1. [Overview](overview.md) | ||
2. [Integration](integration.md) | ||
3. [Customization](custom.md) | ||
4. [Relayer](relayer.md) | ||
5. [Governance Proposals](proposals.md) | ||
|
||
**NOTE**: The IBC module has been moved to its [own repository](https://github.com/cosmos/ibc-go). | ||
|
||
After reading about IBC, head on to the [Building Modules | ||
documentation](../building-modules/) to learn more about the process of building modules. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Not too sure what this does. Where is that plugin added as well?
Could this get a small doc? I am trying to understand how it created those files, as they aren't in
/docs
folder.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.
This is just the action they use in docusaurus, i was having trouble last night getting it to build so trying all options. The custom plugin is specified in
docusaurus.config.js
. It uses all the files from main and any of those that arent the same, they have their own version. Additionally, there is version_config which removes specific files or paths from versions. This way its very clear as to what is in each version when its builtThere 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.
I am not seeing it in the
docusaurus.config.js
. Whichmain
are we talking about? This repo?Ok, so the process of adding a custom content for a version is manual right? If so, this means the versioning is definitely incomplete, won't it be a hell to maintain?
Again, only if my understanding is correct: If I want to change the content only for main, does not this mean I need to first copy the old content to each of the versioned SDK versions, where I want the content to stay the same and then edit the latest content?
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.
lol good catch, I removed this by accident c7d8c0d#diff-a038096cbdea434999e1dce5ab497212f1fe18204dde1a027ce3bdd663261a2aL210
but ill fix this up.
For the second point, the process of adding custom content will be automated. I have been working on a script that for any md file that is updated, removed or added will be copied to the specific version/main within the docs repo.