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

Setup new documentation framework #222

Merged
merged 13 commits into from
Sep 28, 2021
Merged

Conversation

CasperWA
Copy link
Contributor

@CasperWA CasperWA commented Sep 21, 2021

Closes #193.
Closes #195.

This PR sets up a MkDocs framework.

All markdown files have been updated to follow a better git diff strategy with "one-sentence-per-one-line". While it's not a perfect strategy, with obvious shortcomings for "thin" terminals, it still succeeds in bringing much better git diffs than otherwise, where reviewing may become so difficult mistakes are made due to obscurity.

A docs extra is added, meaning one can now install all the Python dependencies needed to build the documentation as well as run a simple server locally by running pip install -e .[docs] (in the future this will be pip install EMMOntoPy[docs].

Invoke tasks have been created and added to a root Python file tasks.py to auto-generate the Python API reference documentation, as well as update the root index.md file in the documentation from the root README.md - changing relative links to match, etc.
These tasks can be used for continuous deployment (CD) of the documentation.

Another task has been added to auto-update the version, where needed, in the code.
This means one can use this in CD of the package when releasing a new version.

I've also added the logo from the Settings page as the "favicon" and general logo of the documentation.

As a note, in order to close #193, we need to decide what should happen with the root folders demo and examples.
According to the referenced issue, it is suggest to move them under docs. In the current PR I have made symbolic links to them for now, but this might as well be settled in this PR together with the setup of the documentation framework.


To test this out, you can checkout this branch (cwa/close-195-mkdocs-framework) and run:

$ pip install -U pip setuptools wheel
Obtaining ...
Successfully installed ...
$ pip install -U -e .[docs]
Obtaining ...
Successfully installed ...
$ mkdocs serve
INFO     - Building documentation ...
...
INFO     - [...] Serving on http://127.0.0.1:8000/EMMO-python/

Then go to the address it prints to your terminal and poke around.


WIth the latest inclusions this now also closes #197.
For more information see this comment below.

@CasperWA CasperWA force-pushed the cwa/close-195-mkdocs-framework branch from bf93187 to e1a2fa1 Compare September 22, 2021 09:39
@CasperWA
Copy link
Contributor Author

CasperWA commented Sep 22, 2021

An example of using versioned documentation can be seen by doing the following:

$ cd /path/to/EMMO-python
$ git fetch origin
$ git checkout cwa/close-195-mkdocs-framework
$ pip install -e .[docs]
$ mike serve -b test-mike
Starting server at http://localhost:8000/
Press Ctrl+C to quit.

Now go to http://localhost:8000 and see how the versioned documentation will look.
Essentially it builds the documentation for each specified version and puts it in a folder (see the file structure of the test-mike branch) and then one can switch between these versions through the dropdown at the top.
I've created some test version here, it's all the same documentation, but the system doesn't know that :) It defaults to the "latest" version, which I've set as an alias for 1.0.3.

If this is desirable, we can implement this type of documentation for the GitHub pages. However, I am unsure whether we shouldn't actually use ontodoc to create the whole documentation instead, or? It seems weird to not use the tools of the package - although, I guess that tool is for creating documentation for ontologies and not Python packages 😉
In any case, it might be good to have the output of using ontodoc as an example to be able to show in the documentation. I'll think about how this can be done.

@francescalb
Copy link
Collaborator

An example of using versioned documentation can be seen by doing the following:

$ cd /path/to/EMMO-python
$ git fetch origin
$ git checkout cwa/close-195-mkdocs-framework
$ pip install -e .[docs]
$ mike serve -b test-mike
Starting server at http://localhost:8000/
Press Ctrl+C to quit.

Now go to http://localhost:8000 and see how the versioned documentation will look.
Essentially it builds the documentation for each specified version and puts it in a folder (see the file structure of the test-mike branch) and then one can switch between these versions through the dropdown at the top.
I've created some test version here, it's all the same documentation, but the system doesn't know that :) It defaults to the "latest" version, which I've set as an alias for 1.0.3.

If this is desirable, we can implement this type of documentation for the GitHub pages. However, I am unsure whether we shouldn't actually use ontodoc to create the whole documentation instead, or? It seems weird to not use the tools of the package - although, I guess that tool is for creating documentation for ontologies and not Python packages 😉
In any case, it might be good to have the output of using ontodoc as an example to be able to show in the documentation. I'll think about how this can be done.

I installed mike with pip install mike, but still get: mike serve -b test-mike
Config value: 'theme'. Error: Unrecognised theme name: 'material'. The available installed themes are: readthedocs, mkdocs
Config value: 'markdown_extensions'. Error: Failed loading extension "pymdownx.highlight".
Config value: 'plugins'. Error: The "mkdocstrings" plugin is not installed
error: Aborted with 3 Configuration Errors!

Can you include documentation on what is needed to make it locally?

@CasperWA
Copy link
Contributor Author

I installed mike with pip install mike, but still get: mike serve -b test-mike
Config value: 'theme'. Error: Unrecognised theme name: 'material'. The available installed themes are: readthedocs, mkdocs
Config value: 'markdown_extensions'. Error: Failed loading extension "pymdownx.highlight".
Config value: 'plugins'. Error: The "mkdocstrings" plugin is not installed
error: Aborted with 3 Configuration Errors!

Can you include documentation on what is needed to make it locally?

Yes, you need to follow my instructions and install the package with the docs extra :)
Either that or you can do it more "manually" by installing the requirements for the documentation directly from the requirements_docs.txt file, i.e.: pip install -r requirements_docs.txt.

@francescalb
Copy link
Collaborator

francescalb commented Sep 23, 2021 via email

@CasperWA
Copy link
Contributor Author

That is what i did: pip install -e .[docs]

(as per your instructions) and the error message reported is what I got.

Manual setup works, but the instructions as written do not.

Fair enough 😅 Sorry for the apparent badgering then. I'll check out why it doesn't work, it should 😕 oh well 😄

@francescalb
Copy link
Collaborator

I think this looks very very nice! As for the docs and demo, I am now convinced that we should only have those in the documentation :) We should definitely have documentation on ontodoc, whic is supposed to be for documenting ontologies and not python packages as you already wrote. Is there a way to make binders with this setup for e.g. a jupyter notebook example?

@CasperWA
Copy link
Contributor Author

I think this looks very very nice!

Yay :)
It's using the Materials theme for MkDocs (see here).
Which I think makes it look awesome :)
But good that this work was not in vain.

As for the docs and demo, I am now convinced that we should only have those in the documentation :)

Okay - I'll try to make them a bit nicer then.
I'm still unsure what the different parts of these examples and demos are - like, is the example for emmodoc actually used for the EMMO documentation or is it just an early copy of what is in the EMMO documentation?

We should definitely have documentation on ontodoc, whic is supposed to be for documenting ontologies and not python packages as you already wrote. Is there a way to make binders with this setup for e.g. a jupyter notebook example?

Hmm. I'll see what I can do. Mybinder is quite slow to start up if it hasn't been run in a while, and therefore cached, but it's a good thing to have, at least.

@francescalb
Copy link
Collaborator

to clarify, I think we are more or less at the point that we can make the first release and then make other additions as improvements

@CasperWA CasperWA marked this pull request as ready for review September 24, 2021 09:36
@CasperWA
Copy link
Contributor Author

This is ready for review. It has been greenlit by @francescalb (most likely following up with an "Approved" review), but it would be good to get @jesper-friis's input before merging this in.

Note, on merge this will NOT start publishing new documentation. The existing documentation (see https://emmo-repo.github.io/EMMO-python) will continue as is, one needs to (for now) manually publish this documentation if one wants to. Automating and documenting this is partly part of issue #199. However, I will create a dedicated issue for this.

@CasperWA
Copy link
Contributor Author

Argh, it seems the docs and examples folders were included in the package build. While I've now updated all references to the folders, I don't see why these need to be included in the build? I'd argue for removing them and keeping them only for use with the (new) documentation and for people who clone the repository from GitHub.

@CasperWA
Copy link
Contributor Author

Argh, it seems the docs and examples folders were included in the package build. While I've now updated all references to the folders, I don't see why these need to be included in the build? I'd argue for removing them and keeping them only for use with the (new) documentation and for people who clone the repository from GitHub.

Concerning this, maybe the last two commits here should be reverted and a dedicated PR could be made, instead of trying to both change the package build as well as setup a documentation framework here?

@francescalb
Copy link
Collaborator

How about adding the demo and examples here now separately (copy instead of soft link), so that they are in the documentation from the start, and fix the package(eg remove them) in a separate pr? Maybe this is what you suggested?

@CasperWA
Copy link
Contributor Author

How about adding the demo and examples here now separately (copy instead of soft link), so that they are in the documentation from the start, and fix the package(eg remove them) in a separate pr? Maybe this is what you suggested?

Yeah, this is what I suggested. However, I would keep the soft links for now, as I see no reason to pollute the history with even more MB :)

@francescalb
Copy link
Collaborator

How about adding the demo and examples here now separately (copy instead of soft link), so that they are in the documentation from the start, and fix the package(eg remove them) in a separate pr? Maybe this is what you suggested?

Yeah, this is what I suggested. However, I would keep the soft links for now, as I see no reason to pollute the history with even more MB :)

OK :)

@CasperWA CasperWA force-pushed the cwa/close-195-mkdocs-framework branch from 2b8077f to 3f3134b Compare September 27, 2021 08:44
Copy link
Collaborator

@jesper-friis jesper-friis left a comment

Choose a reason for hiding this comment

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

Looks great. Had a few comments

README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
docs/index.md Show resolved Hide resolved
@CasperWA CasperWA merged commit dc62efc into master Sep 28, 2021
@CasperWA CasperWA deleted the cwa/close-195-mkdocs-framework branch September 28, 2021 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants