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

Build docs to gh-pages with github actions #353

Merged
merged 5 commits into from
Apr 29, 2023

Conversation

idbrii
Copy link
Contributor

@idbrii idbrii commented Jun 23, 2021

Related #332.

Builds docs to the gh-pages branch on every push to master. Also updates all dead links to point to live ones (or ones that will be live after this is merged).

Builds the documentation for ldoc using the checked out version of ldoc
and uses peaceiris/actions-gh-pages to publish.

Once merged, docs will be available on https://lunarmodules.github.io/LDoc

Currently, you can see the built docs on https://idbrii.github.io/lua-ldoc/manual/doc.md.html


After merging and the build cycles once, an owner needs to enable gh-pages on github: Settings > Pages and set "Source" to gh-pages and root.

Then all the dead links should be fixed. I'd recommend changing the project url in github to https://lunarmodules.github.io/LDoc/manual/doc.md.html which is the first useful page of the docs.

!! I didn't change the rockspec links because that change was already started in #332.

I think it's useful to have a guide for auto running ldoc, but maybe penlight would be a better example since it would have to install ldoc but it's publishing the docs to the repo itself instead of to a separate branch.

Related lunarmodules#332.

Add doc-site target to make file and yml file to build the docs.
Following domenic's guide [1] but using leafo's gh actions like
luacheck.yml.

Builds the documentation for ldoc using the checked out version of ldoc
and uses peaceiris/actions-gh-pages to publish.

Once merged, docs will be available on https://lunarmodules.github.io/LDoc

[1]: https://gist.github.com/domenic/ec8b0fc8ab45f39403dd
* Change stevedonovan.github.io -> lunarmodules.github.io for LDoc.
* Change stevedonovan.github.com -> stevedonovan.github.io (.com is
  obsolete)
* Fix link format for examples. Files are (now?) posted as
  colon.lua.html so we need to .lua extension in the url.
* Fix release link for ldoc to a valid one.
Help people run the same process themselves.
@AntumDeluge
Copy link
Contributor

@idbrii Thanks for this. I have started using it for my own projects.

@alerque
Copy link
Member

alerque commented Aug 1, 2021

Thanks for this contribution. I'll look it over, but it might be WE before I am able to properly evaluate.

@AntumDeluge
Copy link
Contributor

This needs a rebase I believe.

@Tieske
Copy link
Member

Tieske commented Aug 2, 2021

not sure about this, typically the gh-pages branch contains the published docs, and should have the docs for the latest released version. Not master imo. Typically I keep the generated docs in a /docs folder, but only update them on a release (also to not pollute each PR commit with docs changes).

I've been bitten by this several times, and must say I haven't made up my mind entirely yet... my 2cts

@AntumDeluge
Copy link
Contributor

AntumDeluge commented Aug 2, 2021

Workflows can be configured to only deploy with new tags:

on:
  push:
    tags:
    - '*'

@alerque
Copy link
Member

alerque commented Aug 2, 2021

As @Tieske comments, this actually opens up a whole can of worms. The current documentation site makes no note about what version it documents, only what version of ldoc it was generated with. Presumable those are the same but it shouldn't be assumed. Really we should find a way to have versioned documentation (see e.g. how Rust crates document by version, mdbook for example).

In the mean time:

  1. Until we have separate versions, our documentation site should absolutely be for the last released version, not master.
  2. It should identify the release it is documenting.
  3. We should not be polluting master with a bunch of doc commits, nor I think the gh-pages branch. At least until such a time as we have a dedicated docs namespace for the devel version we don't need an update to pages after ever commit. When we do have namespaces for different docs the docs should probably be in a different repo altogether.

More later (WE+) when I can review further. I'm sure there are things we can do to improve the current situation, but probably not in exactly this form.

- master
push:
branches:
- master
Copy link
Contributor

@AntumDeluge AntumDeluge Aug 2, 2021

Choose a reason for hiding this comment

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

Change this to:

 on:
-  pull_request:
-    branches:
-    - master
   push:
-    branches:
-    - master
+    tags:
+    - 'doc-v*'

... (or something similar) and documentation can be versioned by creating tags prefixed with doc-v:

$ git tag doc-v1.4.6

This way, docs will only be rebuilt on gh-pages branch when one of these tags is pushed.

@Tieske
Copy link
Member

Tieske commented Aug 2, 2021

@alerque I'd love to see multiple versions of the docs generated 👍

@AntumDeluge
Copy link
Contributor

AntumDeluge commented Aug 2, 2021

@alerque I'd love to see multiple versions of the docs generated 👍

This could be accomplished by adding a command or shell script like the following to the workflow:

Old:
mkdir doc_builds
for tag in $(git tag | grep "^doc-v"); do
  git checkout ${tag}
  make doc-site
  mv out doc_builds/${tag}
done

Edit: build_versioned_docs.sh

@AntumDeluge
Copy link
Contributor

AntumDeluge commented Aug 3, 2021

Here is a live example I threw together from my build_docs branch (which is this PR rebased on master with some changes to the workflow).

Note: "latest" is most recent doc tag (e.g. latest is the same as 1.4.6-dev).

Not sure why usage info didn't show up.

@idbrii
Copy link
Contributor Author

idbrii commented Aug 10, 2021

@AntumDeluge Nice work on the multiple versions! The mdbook example includes a version selector inside the doc page, so I guess ldoc would need to be updated to support built-in version selection. Maybe the spartan index page is sufficient for now because mostly you'd link directly to a specific version?

You might want to make the index link directly to manual/doc.md.html since that's where the primary content lives.

Not sure why usage info didn't show up.

I believe the usage shows up strangely because ldoc doesn't use a comment for usage.

At least until such a time as we have a dedicated docs namespace for the devel version we don't need an update to pages after ever commit. When we do have namespaces for different docs the docs should probably be in a different repo altogether.

@alerque I don't understand what you mean by namespaces (https://github.com/lunarmodules/LDoc-docs ?) but maybe the structure of AntumDeluge's gh-pages solves that problem.

The main thing that's missing now after AntumDeluge's work is showing the current project version on the generated doc page. I think we'd want that to be an argument to ldoc (instead of in config.ld) to make life easier for automation: --projectversion 0.1.0. Alternatively, we might be able to pass in via the existing --project .

@alerque
Copy link
Member

alerque commented Apr 29, 2023

I would be happy to see another PR that gets multiple-version output going for this repo and/or any LDoc project, but in the interest of getting URLs updated and a release out we'll go with just this building the current version for now.

@alerque alerque merged commit 23ba4af into lunarmodules:master Apr 29, 2023
@idbrii idbrii deleted the build-docs branch May 1, 2023 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants