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

Support for maintaining old/multiple versions of site/documents by enabling ghpagesKeepVersions flag. #39

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

kpritam
Copy link

@kpritam kpritam commented Feb 1, 2018

Fixes #10

@lightbend-cla-validator
Copy link

Hi @kpritam,

Thank you for your contribution! We really value the time you've taken to put this together.

Before we proceed with reviewing this pull request, please sign the Lightbend Contributors License Agreement:

http://www.lightbend.com/contribute/cla

@kpritam
Copy link
Author

kpritam commented Feb 1, 2018

Signed Lightbend CLA

@kpritam
Copy link
Author

kpritam commented Nov 28, 2018

Is there any other better way to maintain versioning in ghpages published docs?

@julienrf
Copy link

julienrf commented Mar 2, 2020

@kpritam This contribution looks great! Do you mind adding a test for it? (in the sbt-test directory)

@kpritam
Copy link
Author

kpritam commented Mar 28, 2020

@kpritam This contribution looks great! Do you mind adding a test for it? (in the sbt-test directory)

I have added test, do have a look and let me know if thats fine.

README.md Outdated
Behind the scenes, this flag plays two important roles:
1. Set's the `includeFilter in ghpagesCleanSite` to include all the files from current versions.
(That means, if you publish same version again, old content from that version will be replaced by new content)
2. While publishing site to gh-pages, new directory with current version's name is created and all the site contents will be
Copy link

@julienrf julienrf Mar 30, 2020

Choose a reason for hiding this comment

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

I think the fact that all the mappings will all be prefixed with the version number should be more emphasized.

Also, how would you recommend to do to have a page that automatically points to the latest version?

Copy link
Author

Choose a reason for hiding this comment

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

For automatic pointing, we can copy latest version at top level as well as inside respective version directory. This can be filtered for snapshot versions which can reside only inside respective snapshot dirs.
We are doing exactly same here:
https://github.com/tmtsoftware/sbt-docs/blob/master/src/main/scala/org/tmt/sbt/docs/Settings.scala

Copy link

@julienrf julienrf Mar 30, 2020

Choose a reason for hiding this comment

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

we can copy

You mean sbt-doc or the users of sbt-doc? (Edit: sorry I meant sbt-ghpages)

Copy link
Author

Choose a reason for hiding this comment

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

In the GhpagesPlugin, when creating ghpagesPrivateMapping check can be added to detect if its a SNAPSHOT version or not and based on that generate mappings. Something like below:

  private def ghpagesPrivateMappingsTask = Def.task {
    val isSnapshot = version.value.contains("SNAPSHOT")
    val makeSiteMappings = (mappings in SitePlugin.autoImport.makeSite).value
    
    val updatedMappings =
      if (ghpagesKeepVersions.value) {
        val updated = makeSiteMappings map { case (file, target) => (file, 
        version.value + "/" + target) }
        if(isSnapshot) upadated
        else makeSiteMappings ++ updated
      }
      else makeSiteMappings

    updatedMappings
  }

Copy link
Author

Choose a reason for hiding this comment

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

sbt-doc uses ghpages plugin, I have added workaround I mentioned above in sbt-doc plugin. As currently ghpages plugin does not support versioning.

Choose a reason for hiding this comment

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

OK. Do we want to add a setting key letting users control whether they want to have their website at the root in addition to have it prefixed by the version number?

Copy link
Author

Choose a reason for hiding this comment

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

Sure, make sense!

Copy link
Author

Choose a reason for hiding this comment

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

I have incorporated all these points in my last commit, let me know if those make sense!

…agesCopyLatestVersionAtRoot key, update README and test accordingly
@julienrf
Copy link

julienrf commented Apr 6, 2020

Another question is coming to my mind. I am still not sure whether maintaining multiple versions should be done at the sbt-site level or sbt-ghpages level… With your proposal, would it be possible and easy to publish a website for v1.0 of a lib, then publish for v2.0, and then for v1.1 but while still having the website for 2.0 by default?

@kpritam
Copy link
Author

kpritam commented Apr 6, 2020

With your proposal, would it be possible and easy to publish a website for v1.0 of a lib, then publish for v2.0, and then for v1.1 but while still having the website for 2.0 by default?

As per the current proposal, last published version is copied to root directory as it does not know about previously published versions.
Simplest way to achieve what you described could be setting ghpagesCopyLatestVersionAtRoot := false while releasing v1.1 (consumer of ghpages responsibility)
Or We could somehow keep track of published version and then sort and decide what goes at top level Or We could peek into current gh-pages repo to see what versions are published.

Another question is coming to my mind. I am still not sure whether maintaining multiple versions should be done at the sbt-site level or sbt-ghpages level…

ghpages plugin cleans repository at the time of every publish, hence this needs to be done in ghpages plugin.

@julienrf
Copy link

julienrf commented Apr 6, 2020

ghpages plugin cleans repository at the time of every publish, hence this needs to be done in ghpages plugin.

Alternatively, we could create a new folder for old versions each time we start a new major branch.

@kpritam
Copy link
Author

kpritam commented Apr 6, 2020

ghpages plugin cleans repository at the time of every publish, hence this needs to be done in ghpages plugin.

Alternatively, we could create a new folder for old versions each time we start a new major branch.

This will force keeping older versions. What if people do not want older versions like the way ghpages currently behaves?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document how to keep older api docs around
3 participants