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 and publish manual with mdBook #47

Merged
merged 4 commits into from
Jun 6, 2024
Merged

Build and publish manual with mdBook #47

merged 4 commits into from
Jun 6, 2024

Conversation

alexdewar
Copy link
Collaborator

@alexdewar alexdewar commented Jun 5, 2024

This PR adds some skeleton files for the documentation and adds a CI workflow to build them with mdBook and publish to GitHub Pages. I've tested it by manually running the workflow. You can see the results here: https://energysystemsmodellinglab.github.io/MUSE_2.0/

The API documentation is still being published to GitHub Pages too; it's accessible via a link on the main page.

Closes #36.

Copy link

codecov bot commented Jun 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.81%. Comparing base (e237e28) to head (0232e77).

Current head 0232e77 differs from pull request most recent head 76fcbad

Please upload reports for the commit 76fcbad to get more accurate results.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #47   +/-   ##
=======================================
  Coverage   81.81%   81.81%           
=======================================
  Files           7        7           
  Lines          77       77           
=======================================
  Hits           63       63           
  Misses         14       14           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alexdewar alexdewar marked this pull request as ready for review June 5, 2024 14:17
@alexdewar alexdewar requested a review from dalonsoa as a code owner June 5, 2024 14:17
Copy link
Collaborator

@dalonsoa dalonsoa left a comment

Choose a reason for hiding this comment

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

I've a couple of questions, but otherwise it looks OK!

- name: Build docs with mdBook
run: |
# Clean repo first
rm -rf book
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should not be needed if book is gitignored, as it is, now.

cargo doc --no-deps

# Put API documentation in with book
rm -r book/api/*
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there anything in api just after running mdbook build?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep. There's the readme file I put in docs/api. But you're right that that should probably just
be replaced with a .gitkeep file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, there is the muse2 folder (containing only a .gitkeep file), so we do still need to clean the folder out otherwise we get an error because muse2/ already exists.

- name: Add redirect
run: echo '<meta http-equiv="refresh" content="0;url=muse2/index.html">' > target/doc/index.html
- name: Install mdBook
run: cargo install mdbook
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there no such a thing as doc dependencies or dev dependencies in rust? If so, this dependency should go in that section and here just install those, so the same setup can be used when building the documentation locally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point! Seemingly there's no such thing as doc dependencies in cargo, but there is dev
dependencies, so I'll add mdBook there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've had a look and this sadly doesn't seem possible currently 😞. I think this is the relevant upstream issue: rust-lang/cargo#9096

The problem is that cargo won't let you have an executable as a dependency. You can add mdbook as a dep, but when it installs you don't get the mdbook binary.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you need this placeholder for? If it is just for keeping the directory structure, you can add a .gitkeep file. See https://stackoverflow.com/a/7229996/3778792

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, kind of. It's because we link to it from a markdown folder in docs/, so if the folder doesn't exist then the markdown link checker complains. But a .gitkeep file is a better idea.

@alexdewar alexdewar force-pushed the mdbook branch 2 times, most recently from df5e762 to a673e11 Compare June 6, 2024 09:40
@alexdewar alexdewar enabled auto-merge June 6, 2024 14:03
@alexdewar alexdewar merged commit a5d47a3 into main Jun 6, 2024
12 checks passed
@alexdewar alexdewar deleted the mdbook branch June 11, 2024 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add basic documentation and auto-publish to GitHub Pages
2 participants