Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Introduce mkdocs for API documentation #31

Merged
merged 16 commits into from
Mar 23, 2023
Merged

Conversation

lognaturel
Copy link
Member

@lognaturel lognaturel commented Feb 16, 2023

It's helpful to have reference for available functionality in a nicely-rendered way.

Remaining to do:

  • Update action to publish to github pages
  • Update Github config for github pages
  • Add link to published docs to readme

What has been done to verify that this works as intended?

mkdocs serve, looked at the resulting docs.

Why is this the best possible solution? Were any other approaches considered?

My goals for this were:

  • reuse the README. It's helpful to have a single source of truth for landing content
  • use markdown. ODK docs use sphinx which has a lot of nice properties but RST is painful
  • autogenerate docs from existing docstrings
  • provide direct links to each method part of our public API
  • get something minimal up that we can start iterating on

Overall, I'm really happy with mkdocs and mkdocstrings. This was straightforward to put together and I think it looks nice. Unfortunately, it doesn't fit in with the styling of any of our existing docs. I think we can deal with that separately.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

No change to code.

Do we need any specific form for testing your changes? If so, please attach one.

No.

Does this change require updates to documentation? If so, please file an issue here and include the link below.

This is the change to documentation.

Before submitting this PR, please make sure you have:

  • included test cases for core behavior and edge cases in tests
  • run nosetests and verified all tests pass
  • run python bin/pre_commit.py to format / lint code
  • verified that any code or assets from external sources are properly credited in comments

@lognaturel lognaturel force-pushed the mkdocs branch 2 times, most recently from 623babe to 5559733 Compare February 17, 2023 00:48
@lognaturel lognaturel added this to the Next milestone Feb 17, 2023
@lognaturel
Copy link
Member Author

I'd be interested in your high-level thoughts @lindsay-stevens. I believe this will make the library a lot more accessible so I'm eager to get it in. If you have some cycles and can take on the couple of todos at the top that would also be wonderful.

Something else I think we should add are recommendations for error handling. I believe all error states result in exceptions and most provide the raw error message from Central. It would be helpful to document that and I think the info on logging that's in the readme now could be moved to that section as well. I think you're best positioned to write a bit about that.

@lognaturel
Copy link
Member Author

can take on the couple of todos at the top that would also be wonderful

But your high-level feedback is the most important thing and I can take those todos!

@lindsay-stevens
Copy link
Contributor

lindsay-stevens commented Mar 6, 2023

Hi @lognaturel looks good! I haven't used mkdocs so it took a little bit of digging in the docs to get up to speed. I opened a PR in your fork with some suggestions.

About the todo items, I don't have privileges to enable Pages on this repo. But it looks like there's a script mkdocs gh-deploy to take care of publishing. About the actions workflow, it's possible to set a trigger only for edits on certain paths:

on:
  push:
    paths:
      - 'docs/**'
      - 'README.md'

Also I was wondering re: docs if it might be interesting to show a version of app_user_provisioner.py as written using projects.create_app_users().

@lognaturel
Copy link
Member Author

lognaturel commented Mar 7, 2023

Thank you! Hoping I can come back to it near the end of the week.

show a version of app_user_provisioner.py as written using projects.create_app_users().

I don't think it should just be a version, I think it should be a replacement!

@lognaturel
Copy link
Member Author

@yanokwa has requested that I explore doing these docs within https://github.com/getodk/docs so we have more overall consistency.

@lognaturel
Copy link
Member Author

I don’t see a great short-term path to a more integrated docs experience. I’ve discussed with @yanokwa and we’re going to start with this so there’s at least some easy-to-use documentation. We can iterate and redirect as needed.

@lognaturel
Copy link
Member Author

I had to remove pywin32==305 to install on my Mac.

lognaturel and others added 13 commits March 23, 2023 13:32
- mkdocs pulls in ~75 deps on top of dev's ~25 so separate
  them to try to avoid dependency issues.
- explicitly name the docs pages to try to make it clearer that forms/subs/projs
  are attributes of the Client. As main sections they seem like they're separate
  classes or topics. Nesting these into a collapsible section seems unnecessary
  because currently they are a main purpose of the documentation.
- move the header documentation in projects, forms, submissions into the classes
  since it is useful info for docstrings to have.
  - while it may be possible to use a script to avoid having the remaining stub
    files with autodoc instructions, it seems unnecessary for only 4 files.
- add docstrings for Client.open / close so that they show up in the docs.
- README:
  - fix indentation of the Client methods list, it didn't render properly.
  - add section on "Errors raised by pyODK".
  - remove relative links to Examples library for now because it won't work
    on both GitHub and rendered docs - replace later with links to the published docs.
  - move README.md in project root, so it is in the most obvious place.
    - add explicit mkdocs "watch" item to ensure README changes trigger reload.
    - add "index.md" with a snippet instruction, to copy over the README content.
- add ODK logo
  - svg minimised: removing some raster shadowing around the border cuts the
    file size from 128KB to 2KB. Imperceptible difference at the size it's rendered
    at, particularly with a dark background.
- add basic light/dark mode.
- add repo url/name to link to GitHub
- sort the theme/features and mkdocstrings/options dicts for legibility.
@lognaturel lognaturel marked this pull request as ready for review March 23, 2023 21:32
Copy link
Member

@yanokwa yanokwa left a comment

Choose a reason for hiding this comment

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

LGTM

@lognaturel lognaturel merged commit 86d01fa into getodk:master Mar 23, 2023
@lognaturel lognaturel removed this from the Next milestone Mar 12, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants