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

test versioning #38

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions docs/src/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineConfig } from 'vitepress'
import { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'
import mathjax3 from "markdown-it-mathjax3";
import footnote from "markdown-it-footnote";
import { versions } from '../composables/versions'

// https://vitepress.dev/reference/site-config
export default defineConfig({
Expand Down Expand Up @@ -39,10 +40,12 @@ export default defineConfig({
{ text: 'Getting Started', link: '/getting_started' },
{ text: 'Markdown', link: '/markdown-examples' },
{ text: 'Code', link: '/code_example' },
{ text: 'API', link: '/api' }
{ text: 'API', link: '/api' },
{ text: 'versions',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{ text: 'versions',
{ text: 'REPLACE_ME_DOCUMENTER_VITEPRESS',

and then we add the current version (be it dev, preview, or v*) to it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm... note that the items part is the thing that needs to be replaced.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought you had some code in the component to make items dynamic?

items: versions},
],

sidebar: 'REPLACE_ME_DOCUMENTER_VITEPRESS',
sidebar: 'REPLACE_ME_DOCUMENTER_VITEPRESS', // this should also be a composable
editLink: {
pattern: 'https://github.com/LuxDL/DocumenterVitepress.jl/edit/master/docs/src/:path' // TODO: replace this in makedocs!
},
Expand Down
28 changes: 28 additions & 0 deletions docs/src/composables/versions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { ref, onMounted } from 'vue'
export const versions = [
{text: 'stable', link: '/',},
{text: 'dev', link: '/dev/',},
{text: 'v0.0.3', link: '/v0.0.3/'}
]

// shared data across instances so we load only once.
// const versions = ref([])

// const dataHost = 'https://github.com/LuxDL/DocumenterVitepress.jl/blob/gh-pages/'
// const dataUrl = `${dataHost}/versions.js`
Comment on lines +11 to +12
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use this instead?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way it's synced with versions.jsfor all items. See e.g. https://geo.makie.org/versions.js

Copy link
Collaborator Author

@lazarusA lazarusA Feb 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄 , how? the issue is getting that list automatically? maybe from the Julia side then, read, parse and include? no idea.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could get the list by e.g.:

const dataHost = 'https://luxdl.github.io/DocumenterVitepress.jl'
const dataUrl = `${dataHost}/versions.js`

see e.g. https://luxdl.github.io/DocumenterVitepress.jl/versions.js

but I'm not sure how the list would be constructed - or how it should be structured!

Copy link
Collaborator Author

@lazarusA lazarusA Feb 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the template:

versions = [
  {text: 'stable', link: '/v0.0.3/',},
  {text: 'dev', link: '/dev/',},
  {text: 'v0.0.3', link: '/v0.0.3/'}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just remembered that I once added some version support for the mkdocs build (via mike), where I hooked into Documenter.HTMLWriter.generate_version_file: https://github.com/thofma/Hecke.jl/blob/master/docs/make.jl#L26-L52. I don't know where that list comes from, but it seemed to work well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could work as a first pass. My issue with it is that it creates a static version selector, meaning that people on docs of v0.4 could not access v0.6 through the selector.

If possible, the best thing to do is probably to somehow access versions.js in the browser and generate a selector on the client side...


// export function useSponsor() {
// onMounted(async () => {
// if (versions.value) {
// return
// }

// const result = await fetch(dataUrl) // Access-Control-Allow-Origin error
// // const json = await result.json() // as text instead

// // versions.value =
// })
// return {
// versions,
// }
// }
Loading