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

deploy docs on github pages #40

Merged
merged 4 commits into from
Apr 2, 2022
Merged

Conversation

zjp-CN
Copy link
Contributor

@zjp-CN zjp-CN commented Mar 24, 2022

This PR is very simple and may help to show docs under distinct and incompatible features, which is related to #36.

feature deployed doc sample
use_tokio https://zjp-cn.github.io/nvim-rs/use_tokio/nvim_rs
use_async-std https://zjp-cn.github.io/nvim-rs/use_async-std/nvim_rs

Note:
This will create a gh-pages branch, and you have to set the source:
image
The generated files look like these.


Licensing: The code contributed to nvim-rs is licensed under the MIT or
Apache license as given in the project root directory.

@KillTheMule
Copy link
Owner

Hey thanks for the PR!

That seems like a feasible approach, but we don't need the "use_neovim_lib" feature, that's for testing/benchmarking only.

Is there a way to check that we're documenting all features this way? E.g. we might add "use_glib" in the future, could this workflow error out in that case, so we don't forget to add the docs?

@zjp-CN
Copy link
Contributor Author

zjp-CN commented Mar 26, 2022

we don't need the "use_neovim_lib" feature

This is easy to remove it from .github/workflows/doc.sh.

Is there a way to check that we're documenting all features this way?

First, these is a way to warn/forbid all the missing docs on all public items and mods:

#![warn(missing_docs)]
#![deny(missing_docs)]

You can see rustdoc/lints.

Second, as for the feature or any cfg banners, you can use the unstable #![doc_auto_cfg] to auto add the banners (due to rust-lang/rust#89596 and rust-lang/rust#90502). Note this needs nightly Rust to get the documentation as expected. Here is a mini example:

# Cargo.toml
[features]
a = []
b = []
//! doc for crate

#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![warn(missing_docs)]

/// doc for feature a and unix
#[cfg(feature = "a")]
#[cfg(unix)]
pub mod a {}

/// doc for feature b
#[cfg(feature = "b")]
pub mod b {}

Run RUSTDOCFLAGS="--cfg docsrs" cargo doc --features a,b --no-deps to see

image

For nvim-rs, steps are:

  1. use
#[cfg(feature = "use_tokio")] 

instead of

#[cfg(feature = "use_tokio")]
#[cfg_attr(docsrs, doc(cfg(feature = "use_tokio")))]
  1. use
#![cfg_attr(docsrs, feature(doc_auto_cfg))]

instead of

#![cfg_attr(docsrs, feature(doc_cfg))]

zjp-CN added a commit to zjp-CN/nvim-rs that referenced this pull request Mar 26, 2022
github-actions bot added a commit to zjp-CN/nvim-rs that referenced this pull request Mar 26, 2022
@zjp-CN
Copy link
Contributor Author

zjp-CN commented Mar 26, 2022

You can check the updated PR and sample documentation above.
Sorry for the duplicated commits, since I'm not familiar with git :)

@KillTheMule
Copy link
Owner

So, ok, I have those settings you showed above (many many thanks for the screenshot, I'd not have managed otherwise :D). Should work, shouldn't it?

@zjp-CN
Copy link
Contributor Author

zjp-CN commented Mar 27, 2022

Oops two CI errors.
For Doc-Deploy error, personally I guess it's due to the GITHUB_TOKEN, because this kind of authentication has no permission to access to external repositories (due to lack of write permissions).
May using deploy_key be a better choice?

@KillTheMule
Copy link
Owner

I did those deploy_key things and retriggered the jobs. Not sure what this windows failure is about, though...

@KillTheMule
Copy link
Owner

The doc job still errors with the same error. I guess you'd need to do this: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-set-ssh-private-key-deploy_key?

@zjp-CN
Copy link
Contributor Author

zjp-CN commented Mar 27, 2022

Yes, now I've replaced with GITHUB_TOKEN with the deploy_key.

@zjp-CN
Copy link
Contributor Author

zjp-CN commented Mar 27, 2022

Seems I need to set that deploy_key too?

@zjp-CN
Copy link
Contributor Author

zjp-CN commented Mar 27, 2022

Now I've set that ACTIONS_DEPLOY_KEY in the forked repo. Could you try again?

@zjp-CN
Copy link
Contributor Author

zjp-CN commented Mar 27, 2022

I see what this means now:

deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}

You need a secret called ACTIONS_DEPLOY_KEY exactly in your repo setting.

Follow here :)

@KillTheMule
Copy link
Owner

KillTheMule commented Apr 1, 2022

Sorry I could not find time for the last few days :)

I've now redone the whole thing. The linked docs are outdated, but now I added ACTIONS_DEPLOY_KEY as an environment secrect for gh-pages, hopefully that works. Let's see!

(e) Naaa didn't work. I've added ACTIONS_DEPLOY_KEY as a repository secret. Maybe that works.

@KillTheMule
Copy link
Owner

No idea what to do now :( You can see what I did here, can you make heads or tails of this?

@zjp-CN
Copy link
Contributor Author

zjp-CN commented Apr 1, 2022

Could you rerun the workflow again now? Because I added ACTIONS_DEPLOY_KEY as a repository secret just now.

@KillTheMule
Copy link
Owner

Just the same :(

@zjp-CN
Copy link
Contributor Author

zjp-CN commented Apr 1, 2022

Well, failed again :(

@zjp-CN
Copy link
Contributor Author

zjp-CN commented Apr 1, 2022

This time Doc CI is ignored due to the new commit :)
I've tested if some repo is owned by me with deploy-secret set like yours, everything is fine to go.
I noticed that a sentence lies on Action Secret web page:

Secrets are not passed to workflows that are triggered by a pull request from a fork.

So you can have this PR merged and then create a new commit on master branch to check whether the doc deployment is successful.

@KillTheMule
Copy link
Owner

So you can have this PR merged and then create a new commit on master branch to check whether the doc deployment is successful.

Alright, let's just try that!

@KillTheMule KillTheMule merged commit c66b7fa into KillTheMule:master Apr 2, 2022
KillTheMule added a commit that referenced this pull request Apr 2, 2022
deploy docs on github pages c66b7fa
@zjp-CN
Copy link
Contributor Author

zjp-CN commented Apr 2, 2022

@KillTheMule
Copy link
Owner

Alright, nice, thanks for your patience.

Now I just need some sort of bannerpage on killthemule.github.io and proper links from the docs/README. And non-broken CI :D

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.

2 participants