Skip to content
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

Docs versioning mechanism #1018

Open
robsontenorio opened this issue Nov 17, 2018 · 23 comments
Open

Docs versioning mechanism #1018

robsontenorio opened this issue Nov 17, 2018 · 23 comments
Labels
type: feature request Request to add a new feature

Comments

@robsontenorio
Copy link
Contributor

Feature request

https://docusaurus.io/docs/en/versioning

You can use the version script to cut a new documentation version based on the latest content in the docs directory. That specific set of documentation will then be preserved and accessible even as the documentation in the docs directory changes moving forward.

What problem does this feature solve?

Create a mechanism to tag versions of docs.

What does the proposed API look like?

Tag a new doc version

yarn run version 5.7

This generate a new folder with tagged docs and includes a dropdown with all available versions. Must be added on default theme.

captura de tela 2018-11-17 as 09 57 48

How should this be implemented in your opinion?

Mostly like Docsaurus does.

Are you willing to work on this yourself?**

No.

@ulivz ulivz added the type: feature request Request to add a new feature label Nov 17, 2018
@ulivz
Copy link
Member

ulivz commented Nov 17, 2018

This is indeed a useful feature, but implementing it must cause breaking changes, first put it aside, and we will introduce RFC process to discuss implementation details.

@luisDanielRoviraContreras
Copy link
Contributor

+1

@robsontenorio
Copy link
Contributor Author

robsontenorio commented Nov 20, 2018

@ulivz I am considering working on this. Can you provide some guide lines in order to avoid breaking changes?

Implementation

In this example didnt touch on core components or core vupress files. Just implement a side lib to make it working. The idea is that can be placed on core system and adjust core components in order to get better integration between search and docs versions (in order to avoid search duplications). Or maybe create a new core component SearchDocs (searchbox + docs dropdown)

Branch

https://github.com/robsontenorio/lighthouse/tree/vuepress

Latest preview

https://5bf559de05c4170ceead6d8f--lighthouse-vuepress.netlify.com/

Directory structure

docs/
├── .vuepress/            
│   ├── config.js         # global site config
│   └── versions.json     # auto-generated versions file
│
├── master/               
│   ├── guides/         
│   │   └── auth.md       # http://mysite.com/master/guides/auth.html
│   ├── the-basics/         
│   │   └── fields.md     # http://mysite.com/master/the-basics/fields.html
│   │ 
│   └── sidebar.js        # versioned sidebar for this version   
│
├── 2.6/               
│   └── ...               # same structure from "docs/master/"
│
├── pages/
│   └── ...               # Not versioned, it remains the same for all docs versions
│
├── package.json          # vuepress dependencies
└── INDEX.md              # the beauty home page

Files

Creating new files

  1. Place the new file into correspondent version folder.
  2. Include the reference for the new file into correspondent sidebar.js, according version number.
# the new file
docs/3.1/guides/cruds.md

# edit the correspondent sidebar
docs/3.1/sidebar.js

Linking files

  • Remember to include the .md extension.
  • Always use relative paths according to folder structure.
The [@paginate](directives.md#paginate) directive is great!

See the [Tutorial](../getting-started/tutorial.md) for more info.

Versions

Each subfolder in docs/ will represent a documentation version, except docs/pages/ that will remain the same for all docs versions.

Path Web route
docs/master/guides/installation.md http://mysite.com/master/guides/installation.html
docs/2.6/guides/installation.md http://mysite.com/2.6/guides/installation.html
docs/pages/users.md http://mysite.com/pages/users.html

Updating a existent version

You can update multiples docs versions at the same time. Because each docs/ subfolder represents specifics routes when published.

  1. Edit any file.
  2. Commit and push changes.
  3. It will be published to the correspondent version.

Example: When you change any file from docs/2.6/, it will publish changes only for 2.6 docs version.

Tagging a new version

  1. First, finsh your work on docs/master . A version always should be based from master.

  2. Enter a new version number

yarn docs:version 3.1
  1. Commit and push.

  2. It will be published as the last documentation version.

When tagging a new version, the document versioning mechanism will:

  • Copy full docs/master/ folder contents into a new docs/<version>/ folder.
  • Place a new version number in docs/.vuepress/versions.json

@maziarz
Copy link

maziarz commented Jan 8, 2019

Any update on this issue? Would really like to contribute where possible, as i am depending on this feature.

@amimas
Copy link

amimas commented Jan 11, 2019

Is this feature being considered for the next version (1.x)?

@nklayman
Copy link

Now that 1.0 is released, could this be created as a plugin? The plugin api appears to be quite powerful as there is a blog plugin. @robsontenorio would it be possible to move your work to a plugin?

@janvennemann
Copy link
Contributor

janvennemann commented Jul 30, 2019

We have been working on a plugin that does versioning in VuePress. It's still in the early stages but we released a first version a couple of days ago. It's pretty similar to how Docusaurus does versioning so there are a few differences to @robsontenorio approach.

Overview

  • Docusaurus style versioning ported to VuePress
  • vuepress version <sourceDir> <versionNumber> command to draft new versions
  • Current version of your docs stay in the VuePress source folder. A snapshot of your docs will be copied to website/versioned_docs when a new version is created. Also snapshots your current sidebar config and stores it with the version.
  • Configurable extra pages folder for unversioned documents (under website/pages by default).

Guide and Demo

Please check out the guide and demo of the plugin here: https://titanium-docs-devkit.netlify.com/guide/versioning.html

The plugin requires a modified theme that is able to handle versioned pages to properly generate links, which you can also find under the link above.

Known issues

  • Permalinks are currently not supported. Paths for pages will be changed based on what version the page is part of. The permalink option is currently ignored during that process and results in duplicate pages.
  • Not tested yet with other major plugins, like the blog plugin for example.

@florimondmanca
Copy link

That sounds promising @janvennemann!

Extra pages folder under website/pages for unversioned documents.

Would it make sense to store versioned content in a dedicated folder, instead of non versioned content? This would allow to have extra pages anywhere and not place any extra constraints on folder structure. My intuition is that this could make discriminating versioned content easier as well. :-)

@janvennemann
Copy link
Contributor

janvennemann commented Jul 30, 2019

In our use case everything in the docs source folder needs to be versioned anyway and only a few extra pages are exempt from that. That's the reason we choose it that way around. The folder website/pages is not hardcoded btw and can be configured in the plugin options.

But i see that for others only a specific folder could be of interest to be considered for versioning. I already thought about a exclude/include kind of option which could probably allow that. I'll put that on the todo list.

@my9074
Copy link

my9074 commented Sep 10, 2019

@janvennemann In some docs, we need to display the dynamic version number. After version control is implemented, can you satisfy the variables that reference the version in the document fragment?

image

@jankeromnes
Copy link
Contributor

Hello! 👋 I think you meant @janvennemann. 🙂 Deferring the question to them.

@janvennemann
Copy link
Contributor

@my9074 Usually you access the version of a particular page via $page.version. However, I don't think that's easily done in your particular case since it is inside a fenced code block that will be pre-rendered and you don't have access to Vue interpolation there.

There may be a fancy solution using script hoisting and then search & replace a marker with $page.version but i haven't actually used that yet. You easiest bet is to manually maintain the correct version number in your fenced code blocks.

@about-code
Copy link

about-code commented Sep 22, 2019

Just a side-node (or user story): Collaborative docs are often maintained in a VCS like git, on GitHub, or Gitlab servers where you tag a revision of your source tree. From GitHub or GitLab you can directly clone/pull tagged versions of a documentation via URLs.

The OP seems to use the term tagging as adding a new versioned subfolder. If I use the term tag below I refer to git tags, so labels for a particular commit or state of a repository.

While an RFC certainly needs to specify the directory layout for building, thus including version directories makes sense, it would be cool if a final implementation would be able to pull these versioned directories directly from git tags. Then anything apart from master could be .gitignore-ed. Version state wouldn't become part of the source tree. I think of something similar to what Antora does, for example.

Otherwise it may happen to have a commit with a v2.6 version folder on a "master" branch being changed after a v2.6 git tag has been set on an earlier revision. This undermines git tags, effectively and also makes diffs between versions a lot harder.

@janvennemann
Copy link
Contributor

Interesting use case! This would require some kind of branch management and logic to merge the docs from different branches into one big final build. Although probably possible with the really powerful plugin system, IMHO that complicates things by a certain degree. However, definitely an interesting alternative to having the versioned docs all checked into one branch.

@robsontenorio
Copy link
Contributor Author

robsontenorio commented Sep 24, 2019 via email

@about-code
Copy link

about-code commented Sep 25, 2019

@janvennemann

This would require some kind of branch management and logic to merge the docs from different branches into one big final build. Although probably possible with the really powerful plugin system, IMHO that complicates things by a certain degree.

I think there could be different incremental steps.

  1. The first stage paves the way for a minimal solution satisfying the core use case. It compiles docs from version folders, no matter how they are being created, manually or via some kind of checkout. The proposals so far seem all equally well suited for solutions likely to provide enough added value for many people.
  2. In a second stage 'on top' of this first stage prebuild scripts may be added which are capable to detect whether there's a .git folder, and if so to recreate the vX.Y-folders from the git history. They could be using the git CLI to find out about tags, tagnames and to restore a particular commit state from the current repo clone, since all info is in its history.
  3. A third stage might add full branch support, if there's demand for and developer capacity. Personally I'd already be happy with a stage 2 feature.

Said this, all three stages would be worth their own issues, so I aggree with keeping this one the thread for kind of a "stage 1" solution.

@smrbts
Copy link

smrbts commented Oct 11, 2019

Any word from the Vuepress team if this is something they have on their radar for the near future? Really enjoy using the default theme for our docs, but the lack of versioning is really going to be a problem moving into the future.

@metasean
Copy link

metasean commented Nov 5, 2019

It looks like the RFC process is now in place (https://github.com/vuejs/vuepress/tree/master/rfcs).

@robsontenorio , @janvennemann , & @about-code - Y'all look like you have the most fleshed out concepts. Any chance one of you is willing to start the RFC process?

@robsontenorio
Copy link
Contributor Author

robsontenorio commented Nov 5, 2019 via email

@about-code
Copy link

@robsontenorio , @janvennemann , & @about-code - Y'all look like you have the most fleshed out concepts [...]

Hmm, I wouldn't use the terms fleshed out or concept myself ;-). My ideas have really just been ideas :-)

@metasean
Copy link

Anybody interested in this, please help flesh out #2018 with your ideas, concerns, interests, etc.

@axieum
Copy link

axieum commented Feb 19, 2020

Another thing to take into account, is the combination of locale and version. I believe the URL should show as en-GB/1.0/*, but the file structure should be 1.0/en-GB/*. This may cause issues with the VuePress path resolving as the URL would not reflect the relative path.

@arvindanta
Copy link

Can we inject scripts in the head based on the sidebar route ?

I have the below sidebar config. Can I Inject particular version of script for each sidebar route ?

      {
        '/v2/': [ { title: 'Getting Startedv2' }, { title: 'Getting Startedv21' } ],
        '/v3/': [ { title: 'Getting Startedv3' }, { title: 'Getting Startedv31' } ]
      }
    ,```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request Request to add a new feature
Projects
None yet
Development

No branches or pull requests