-
Notifications
You must be signed in to change notification settings - Fork 95
Implement docs with sphinx #508
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
Conversation
@@ -0,0 +1,260 @@ | |||
.. toctree:: |
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 file is the main entry point for sphinx when the static site is regenerated.
The .. toctree::
directive is how navigation is defined and dictates what other content is pulled in.
@@ -0,0 +1,126 @@ | |||
======== |
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.
To determine what methods are actually documented, they need to be declared in an rst file that is mentioned in the root toctree
. Currently we have three things we're documenting: Pinecone
in rest.rst
, PineconeAsyncio
in asyncio.rst
, and PineconeGRPC
in grpc.rst
.
> [!NOTE] | ||
> The official SDK package was renamed from `pinecone-client` to `pinecone` beginning in version 5.1.0. | ||
> Please remove `pinecone-client` from your project dependencies and add `pinecone` instead to get | ||
> the latest updates. |
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.
We're using something called myst-parser
to suck in some content that already existed in the repo as markdown files and render it into the sphinx static site. For the most part it does a good job, but the myst-parser didn't handle this comment block syntax. I think this is a github-specific addition to the markdown syntax, so I guess I'm not surprised.
@@ -1,62 +0,0 @@ | |||
class IndexClientInstantiationError(Exception): |
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.
In the past we were doing some weird stuff where we aliased the real implementation of Index
to _Index
and then threw an error message if anybody tried to directly instantiate the Index
class. I can't remember now, but I think this was something a field engineer requested.
I decided to nix these because it was causing a problem when generating docs. In the past, this was added to chastise people if they tried to instantiate the Index
class without going through a parent client object such as Pinecone
(which was handling a bunch of configuration stuff), but that small benefit is not worth having wonky looking documentation.
@@ -30,6 +30,7 @@ jobs: | |||
if: ${{ always() }} | |||
needs: | |||
- dependency-tests | |||
- create-project |
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.
Since I removed pdoc, this workflow got triggered and I noticed this mistake in my recent "create a project for every test run" PR.
- name: Pretend this project requires Python 3.11 | ||
shell: bash | ||
run: | | ||
# Poetry won't let me install sphinx as a dev dependency in this project | ||
# because of the wide range of versions our library supports. So during this | ||
# action, we'll pretend this project requires Python 3.11 or greater. | ||
sed -i 's/python = "^3.9"/python = "^3.11"/' pyproject.toml | ||
poetry lock | ||
poetry install -E grpc -E asyncio | ||
|
||
- name: Install sphinx | ||
shell: bash | ||
run: | | ||
poetry add sphinx myst-parser --group dev |
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 is a minor atrocity, but for now it's the best way to work around sphinx's relatively narrow python version support. Poetry won't let me install it normally (and add it as a dev dependency in pyproject.toml
) because our library has a wider range of python version support than sphinx
.
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.
Nice work, LGTM!
Problem
Recent changes to implement lazy loading in the SDK have broken compatibility with our previous docs tool, pdoc. After some investigation, it seemed easier to adopt a new docs solution than to try to manipulate pdoc internals to work for our usecase.
Solution
docs
folder. Main points of interest:docs/conf.py
anddocs/index.rst
docs/_static/custom.css
to tweak the look of the default sphinx theme which is using Garamond font and doesn't really match our branding at all. Changing up to use sans-serif fonts and tweaking a few other things gets us a long way there, although I'm sure there are still things to refine on that over time.poetry run sphinx-build -b html docs docsbuild
sphinx
and the publishedpinecone
. Neither one of those sound like good options to me.Type of Change
Testing
New docs visible at https://sdk.pinecone.io/python
I published these by manually triggering the build-and-publish-docs job from this branch