-
Notifications
You must be signed in to change notification settings - Fork 47
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
Put docs in main repo, working API reference #170
Conversation
I'm switched this back to a non-draft pull request. First, you can now preview the live site here: https://docz.opendp.org/en/148-docs/index.html Yes, one we merge, we'll change "docz" to "docs" and make it the live site. I still don't have a solution for "latest" vs "main". The new site (this pull request) will use "main", the default branch. I did open an issue upstream today: Holzhaus/sphinx-multiversion#78 |
.github/workflows/docs.yml
Outdated
cp -r /tmp/build/html/* . | ||
git add --all --force | ||
- name: Push docs to gh-pages branch | ||
if: success() && github.ref == 'refs/heads/main' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How often do we want to update the documentation? Per-merge or per-release?
In this PR #162, CI will release a new python package and crate whenever there is a push to the release
branch. If you tie documentation deployment to the release branch, then the documentation will update less frequently, only when a release is cut.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it could update the docs each merge into main, where the updated docs includes both the latest
branch (renamed from main
) and all of the tags.
Within the CI script, why can't you git branch -D latest && git checkout -b latest
before building to make the generated documentation look as if it were on the latest
branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least for the time being, while docs are being worked on quite actively, I was thinking the docs site should be updated when pull requests were merged.
In this pull request, the updated docs would appear under "main" (docs.opendp.org/en/main), reflecting the fact that the pull request was merged into the main branch.
Assuming a regular release cycle in the future, I'm open to only updating docs on release. That's what we do for Dataverse. That said, even in the context of Dataverse, when we haven't released for a while, I'm often interested in seeing what the updated docs will look like, so I think there's value in always having "main" or "latest" to be able to preview what's coming in the next release.
I guess it could update the docs each merge into main, where the updated docs includes both the
latest
branch (renamed frommain
) and all of the tags.
I'm not sure I fully grok this. Is renaming main
on the table? The extension I'm using does support tags. No problem there. That's my plan for people being able to switch between different versions of the library.
I don't think the checkout
above will work but in the same vein, we might be able to have the CI whatever is in main
to a branch called latest
and then run make versions
. I haven't tried this yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, if we don't rename main, then each time main is pushed to, CI could run something like:
git branch -D latest && git checkout -b latest
make versions
...where smv_branch_whitelist = r'^latest$'
.
By "rename from main" I was referring to the checkout. I don't think I'm the guy to decide if we will rename main. I agree that it makes sense to push docs more frequently. I'm ambivalent on the naming, but wanted to share a method for how you might go about changing the version name without making repository changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. Delete the latest
branch and then create it again from main
. Yeah, I would hope that would work. I was thinking of a merge from main
to latest
but I'm not picky. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just brainstorming. Merges would work too.
docs/source/conf.py
Outdated
# built documents. | ||
# | ||
# The short X.Y version. | ||
version = '0.0.1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was attempting to add some global checks to make sure version numbers across projects are synchronized in the CI release PR. There's a root-level VERSION
file and a .github/assert_version.py
that checks version numbers. I'm not sure if that's how we want to handle things, but if it is, maybe this could read the version from the VERSION file? Perhaps the release CI script could upload a tag based on the contents of that VERSION file too, so we always know the VERSION file is synchronized with the tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I absolutely want us to have a single source of truth for the version. I just threw 0.0.1 in there for discussion. I'm glad you found it. Reading from a file should work, I would imagine.
I just made several commits to get the docs previewing again at https://docz.opendp.org/en/148-docs/index.html This seems necessary if we're going to work on content and various rearranging, as @andrewvyrros has proposed. Before merging, we'll need to revert a number of commits. I thought 66bd776 would be enough to get previews working again. I don't think 21cfbe4 was actually necessary for me to commit but I kept getting "No matching refs found!". In the end |
python/src/opendp/v1/_lib.py
Outdated
|
||
def _get_lib_dir() -> str: | ||
lib = None | ||
if os.environ.get('OPENDP_HEADLESS', "false") == "false": | ||
lib_dir = os.environ.get("OPENDP_LIB_DIR", os.path.join(os.path.dirname(os.path.abspath(__file__)), "lib")) | ||
if not os.path.exists(lib_dir): | ||
# fall back to default location of binaries in a developer install | ||
build_dir = 'debug' if os.environ.get('OPENDP_TEST_RELEASE', "false") == "false" else 'release' | ||
lib_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), *['..'] * 4, 'rust', 'target', build_dir) | ||
if not os.path.exists(lib_dir): | ||
raise ValueError("Unable to find lib directory. Consider setting OPENDP_LIB_DIR to a valid directory.") | ||
return lib_dir | ||
|
||
|
||
def _get_lib_name() -> str: | ||
platform_to_name = { | ||
"darwin": "libopendp_ffi.dylib", | ||
"linux": "libopendp_ffi.so", | ||
"win32": "opendp_ffi.dll", | ||
} | ||
if sys.platform not in platform_to_name: | ||
raise Exception("Platform not supported", sys.platform) | ||
return platform_to_name[sys.platform] | ||
|
||
lib_name = platform_to_name[sys.platform] | ||
|
||
lib_path = os.path.join(_get_lib_dir(), _get_lib_name()) | ||
lib = ctypes.cdll.LoadLibrary(lib_path) | ||
lib = ctypes.cdll.LoadLibrary(os.path.join(lib_dir, lib_name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something seems funky here. Are these changes intended, or is this a merge issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was something I added. The docs build sources the library. If the binaries don't exist, the sourcing fails, so the docs fail to build. So he had to start building the rust binaries from the docs workflow to get the docs to build. This makes it so that if the env var OPENDP_HEADLESS
is set, then the binaries are not loaded, bypassing the need to build the binaries.
I just pushed the content reorg @andrewvyrros and I have been talking about: https://docz.opendp.org/en/148-docs/index.html Please note that many of the pages are blank but the structure is there. Even thought this pull request is a mix of content and deployment, these topics can be discussed separately. For content, I'd like to bring up the following comments or questions
I have lots of thoughts on deployment and CI too:
|
Thanks Phil, this is coming together!
Yeah I think it makes sense to have separate pages under Resources. I think most of the stuff in that issue could fit in a page called References or Educational Material or similar. For Tutorials, I was imagining that being just coding tutorials (like end-to-end instructions focused on a single use case.)
For sure we want to document that. It just felt a little early to have that in our public docs, as we're still inventing it, and don't want to be encouraging people to try to cut their own releases! (@Shoeboxam discovered what seems like an access hole in GH repo permissions around releases.)
The issue tracker and project board stuff is a little tricky, I think that's worth a separate discussion. For Getting Help, I was thinking that kind of stuff could live under Contact. Alternatively, we could have the top-level module be labeled Help, and have various ways of getting help under there?
Yeah I guess it makes sense to have it live under OpenDP Commons.
Yeah something's a little funky there. We probably don't need the second level OpenDP Commons node. Maybe the hierarchy looks like this:
I was thinking it'd be cleaner to push the HTML to a separate repo, and not have publishing artifacts in the main repo. But I've never use GH Pages before, so if there's a compelling reason to keep it in a single repo, I'm open to that.
It's probably a bit aspirational, but doesn't seem to harm anything?
Yeah latest seems reasonable.
Yeah there's always a tradeoff with adopting tools like that. If we have to roll our own solution to get the best docs, then so be it. |
See also the following in source/conf.py TODO: We would rather have "latest" than "main". smv_branch_whitelist = r'^latest$'
**: Matches zero or more of any character. See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
This reverts commit 5471219. Reverting because we started seeing "No matching refs found!" again.
Right now "docs" is copied to the root, along with "rust" and "python/src/opendp/v1/ __pycache__".
An "if" in the "push to gh-pages" prevents updating the live site except on merge. For now, whitelist only "main". Link to new issue about "latest". Also get rid of mentions of 148-docs branch. TODO: change docz CNAME to docs.
Co-authored-by: Michael Shoemate <shoeboxam@gmail.com>
Co-authored-by: Michael Shoemate <shoeboxam@gmail.com>
We'll revert this commit later.
Just trying to get the docs to build. Right now we are seeing "No matching refs found!"
…he-fly with sphinx-apidoc. * Pointed to Rust API docs on docs.rs. * Removed extra Python path entries. * Updated docs/requirements.txt for sphinx 4.1.2, patched sphinx-multiversion. * Cleaned up Makefile for single-version case. * Updated triggers for docs workflow. * Added sync-branches workflow to sync stable and latest branches. * Rebased to main.
I've made it so that the API doc structure is generated dynamically for each release, so we don't have to keep the .rst docs in sync with Python packages. I also came up with a strategy for handling stable and latest branches. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woohoo! Nice to have in-repo docs! Thanks Phil! Thanks Andy!
Closes #148
As part of this pull request, I went ahead and incorporated the Python docs @Shoeboxam added but rather than using his "build docs" script, I tweaked the Sphinx config file. Here's how it looks:
A few things to note:
make html
should work fine but if you want to trymake versions
you'll have to go intosource/conf.py
and change "main" to "148-docs" in the line that sayssmv_branch_whitelist = r'^main$'
smv_branch_whitelist
set to "main" but somehow I'd like the docs for "main" to appear at a URL for "latest". To achieve this in the docs repo, we used "latest" rather than "main" as the default branch but I'm hoping we can avoid this.opendp.v1.meas.rst
when we add a new module. These are basically small index files and if this becomes a problem, we can probably figure out some automation.