Questions and notes from workshop day 6 (Documentation)

Day 6 - 01/10/2025

Let's test the notes with some icebreakers! :icecream:

What did you have for lunch today?

How would you explain your current job to someone in the year 1700? (if you don't know, write what you do and we'll try to figure out!)

What's the best documented project you've seen?

How to document your research software

https://coderefinery.github.io/documentation

Motivation and Wishlist

https://coderefinery.github.io/documentation/wishlist/

Is project documentation important? Why?

How would you describe a useful documentation?

How can you motivate your colleagues to contribute to the documentation?

Your questions here:

  1. How to find a balance between writing documentation, comments in the very code, and time spent on all this?

    • This is a hard question, it depends on the project. If there a are many users, you should spend a lot of time writing documentation. If only a few, portion of time should be low.
    • Test it. Have someone else try and use your documentation. If it works, it was enough. (excellent advice)
  2. Difference between text/ascii and .md and .rst files

    • markdown and rst offer some more options for formatting and "presentation" over pure text, while still being lightweight compared to writing something like latex.
  3. How would I type mathematical expressions in markup languages?

    • Like this: https://github.com/pytorch/pytorch/blob/v2.8.0/torch/nn/modules/instancenorm.py#L127
    • details might depend on what dialect of markdown you are using.
      • Alright, thanks!
    • We have an example with MyST in the lesson material: https://coderefinery.github.io/documentation/sphinx/#exercise-sphinx-and-latex
    • For situations were the answer might depend on fairly arbitrary decisions I tend to look at what the projects in the area I am working in are using. That way the result is likely to be similar to what people there are already used to. That's why "numpy" is pretty much also a documentation style. https://numpydoc.readthedocs.io/en/latest/format.html
  4. Regarding zombie code. I understand why comments should not be used for this purpose. However, sometimes I try to optimize code using various ideas. By keeping my failed attempts as zombie code, I remember them and more importantly, don't try the ideas again. What is the alternative?

    • I tend to have lots of commented code or attempts/debug output that I remove before I make a pull request.
    • Some code snippets that you want to keep around would probably be fine to keep as a comment as part of internal documentation with some additional explanation why you are doing it (not) that way.

Writing good README files

https://coderefinery.github.io/documentation/writing-readme-files/

  1. What tool should I use to properly render the markup language of a readme file on my computer? Can I use an ordinary browser?

    • There are some web based ones. Your browser can usually render markdown. I tend to not bother and just push it to github, where it gets rendered. You can also use hedgedoc/hackmd
      • Alright, thanks! The reason I ask is that ideally, I think it should be possible to read the readme file on your own computer without having to go through github.
        • A lot of readmes will include badges or some kind of additional information pulled from CI/CD or other sources, so at least some of the time you can not get the full version as it would be on the repo.
        • For documentation you can run tools like sphinx locally, which will generate the webpages you can then browse with your webbrowser.
  2. What is alt text?

    • Alternative (I believe it stands for) text that should be added to images, describing the image shown for e.g. screenreaders (so that a blind person would also benefit from the information shown in the image)
  3. When using badges, we link a badge image. Do we need to somehow create our badge image before, or we do that through markdown?

    • Typically badges are available at a site somewhere on the internet, that is linked then in the markdown file. The badges can be "dynamic", in the sense that while the url of the image stays the same, the image itself changes (e.g., when the tests in the continuous integration setup pass, you get a green badge, when the tests don't, you get a red one)
    • If you are making e.g. a test coverage report badge, than there are pre-made github workflows that will help you create that badge as part of your CI pipeline. That workflow will then also commit the generated file to your repo so it can be referenced from the readme.

::: info

Exercise untill XX:58

You can do either of these exercises: README-2: https://coderefinery.github.io/documentation/writing-readme-files/#exercise-improve-the-readme-for-your-own-project README-3: https://coderefinery.github.io/documentation/writing-readme-files/#exercise-discuss-the-readme-of-a-project-that-you-use

Please note observations and recommendations in the collaborative notes. :::

Some example README files

https://github.com/paboyle/Grid https://github.com/opendatalab/MinerU

Any questions about the exercises? Ask below:

  1. Bit confused what we are meant to do?
    • You can choose exercise 2 or 3, there is no need to do both.
    • Either comment on the example README or discuss any questions, or just try out some markdown features on your own README file.
    • Please note observations and recommendations in the collaborative notes.

Question to all: Any comments on README files you have seen or you are working on? (in other words, you can add observations from Exercise README-2 and README-3 here)

  1. One of the READMEs has links to the wiki in the Github repo - is this a good idea?
    • May be hard to keep in sync, but if it is stable, ok
    • Other options than Wiki (for extended documentation) shown in remainder of this session

Sphinx and Markdown

https://coderefinery.github.io/documentation/sphinx/

:::info For the following session, if you want to follow along on your local machine you might need https://coderefinery.github.io/installation/conda/ Join the Virtual Help session (link in e-mail) if you have questions or need technical support :::

Please do type along, if you want to :) You can find all commands in the lesson material: https://coderefinery.github.io/documentation/sphinx/ (you will also have time to do it during the next exercise session)

:::info

Exercise session until XX:55

Start with Sphinx-1 and see how far you get :) Sphinx-1 (was shown by Michele on stream): https://coderefinery.github.io/documentation/sphinx/#exercise-sphinx-quickstart Sphinx-2: https://coderefinery.github.io/documentation/sphinx/#exercise-adding-more-sphinx-content Sphinx-3: https://coderefinery.github.io/documentation/sphinx/#exercise-sphinx-and-latex Sphinx-4: https://coderefinery.github.io/documentation/sphinx/#exercise-sphinx-autodoc :::

Questions regarding the exercise:

  1. I have myst_parser but sphinx cannot import it. What could cause this:
       (coderefinery) user@mint:~/Desktop/Downloads/doc-example$ python -c "import myst_parser"
       (coderefinery) user@mint:~/Desktop/Downloads/doc-example$ sphinx-build . _build
       Running Sphinx v7.2.6
    
       Extension error:
       Could not import extension myst_parser (exception: No module named 'myst_parser')
    
  1. What is the syntax for a numbered list? Any (non-negative) integer followed by a period?
    • Yes (to my knowledge), and they will be automatically renumbered
      • Ok, thanks!

Sphinx documentation to GitHub pages

https://coderefinery.github.io/documentation/gh_workflow/

Please do follow along with Yu to deploy your own sphinx documentation to GitHub. If you prefer, you can also lean back and just watch (and try it out on your own time). https://coderefinery.github.io/documentation/gh_workflow/#exercise-deploy-sphinx-documentation-to-github-pages Repository to clone (to save time): https://github.com/new?template_name=documentation-example&template_owner=coderefinery

Questions continued:

  1. . SUGGESTION: YOU ARE GOING TOO FAST!!!!!

    • Thank you for the feedback! Sorry that it went too fast.
  2. Because we have to do exdercies for homework, right?

    • I don't understand the question. Seems like some context is missing.
    • there are exercises i couldn't finish during the lecture today
      • You are welcome to continue working on them.
  3. If we choose to build a sphinx mini website for the certificate exercise, how big should it be? Like the size of the tutorial we did today or a bit bigger?

    • One page is enough :) but if you are having fun, do something bigger! Try various templates...etc... It's your chance to experiment and learn what you need/want.
  4. If i delete the repo from which a website is built does that also delete the website or do i have to do it separately?

    • In general there is a github action on the repo that builds the website and publishes it. Deleting the repo only removes that process, i.e. any further updates to the page. Generally you would need to delete the existing website separately. Details may depend on the exact configuration you are using.
    • In the context of github pages, deleting the repo (including the branch served on the website) will also delete the website

:::info

Thank you for today!

We hope you learned something new about documentation and can take up some of the tools and techniques into your daily work

Next week we will look at Jupyter Notebooks

You will need the CodeRefinery environment to play around with Jupyter and do the exercises. Even if you think you know Jupyter Notebooks already, you might get something new out of this session!

Continue the discussion and ask questions

You are also welcome to join our community chat at https://coderefinery.zulipchat.com to continue discussions and ask any questions you may have!

:::

Feedback for today

Please let us know how todays session went for you:

Today was (vote for all that apply):

One good thing about today:

One thing to improve for next time:

Any other feedback?

General questions continued:


Funding

CodeRefinery is a project within the Nordic e-Infrastructure Collaboration (NeIC).

Privacy

Privacy policy

Follow us

Contact

support@coderefinery.org

Improve this page

Source code