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

Add reference page to documentation using Sphinx autodoc #312

Merged
merged 15 commits into from Aug 10, 2021
Merged

Conversation

simonw
Copy link
Owner

@simonw simonw commented Aug 10, 2021

Refs #311.

@simonw
Copy link
Owner Author

simonw commented Aug 10, 2021

On Python 3.6:

sqlite_utils/db.py:366: in Database
    def tables(self) -> List[Table]:
E   NameError: name 'Table' is not defined

Python 3.7 can fix this with from __future__ import annotations but since we still support 3.6 I'll have to use a string instead.

@simonw
Copy link
Owner Author

simonw commented Aug 10, 2021

I'm going to get Read The Docs to build the docs for this branch too - on https://readthedocs.org/projects/sqlite-utils/versions/ I am clicking this button:

Versions___Read_the_Docs

I then set it to "active" (so pushes to the branch will build it) and "hidden" (so it wouldn't show up in search or in the navigation menu). https://docs.readthedocs.io/en/stable/versions.html#version-states

autodoc_-_sqlite-utils___Read_the_Docs

@codecov
Copy link

codecov bot commented Aug 10, 2021

Codecov Report

Merging #312 (43bc064) into main (ee469e3) will decrease coverage by 0.02%.
The diff coverage is 96.84%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #312      +/-   ##
==========================================
- Coverage   96.30%   96.28%   -0.03%     
==========================================
  Files           5        5              
  Lines        2168     2179      +11     
==========================================
+ Hits         2088     2098      +10     
- Misses         80       81       +1     
Impacted Files Coverage Δ
sqlite_utils/db.py 97.91% <96.84%> (-0.08%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ee469e3...43bc064. Read the comment docs.

@simonw
Copy link
Owner Author

simonw commented Aug 10, 2021

Docs are now building at https://sqlite-utils.datasette.io/en/autodoc/reference.html

But there's a problem! The page is semi-blank:

Reference_—_sqlite-utils_3_15-6-gc11ff89_documentation

I need to teach Read The Docs how to ensure sqlite_utils is available for introspection.

@simonw
Copy link
Owner Author

simonw commented Aug 10, 2021

https://sphinx-rtd-tutorial.readthedocs.io/en/latest/sphinx-config.html#autodoc-configuration says do something like this at the top of conf.py:

import os
import sys
sys.path.insert(0, os.path.abspath('../../simpleble/'))

@simonw
Copy link
Owner Author

simonw commented Aug 10, 2021

Reading the rest of https://sphinx-rtd-tutorial.readthedocs.io/en/latest/sphinx-config.html#autodoc-configuration it suggests using a requirements.txt file to install dependencies - but I use setup.py for that so I need to figure out a different pattern here.

@simonw
Copy link
Owner Author

simonw commented Aug 10, 2021

From https://docs.readthedocs.io/en/stable/config-file/v2.html#packages it looks like I can tell Read The Docs to run pip install -e . using a .readthedocs.yaml configuration:

version: 2

sphinx:
   configuration: docs/conf.py

python:
  version: "3.9"
  install:
    - method: pip
      path: .
      extra_requirements:
        - docs

@simonw
Copy link
Owner Author

simonw commented Aug 10, 2021

@simonw
Copy link
Owner Author

simonw commented Aug 10, 2021

Adding type signatures to create_table() and .create_table_sql() is a bit too involved, I'll do that in a separate issue.

@simonw
Copy link
Owner Author

simonw commented Aug 10, 2021

Spotted a rogue backtick:

A0147E27-7506-49B0-BEFB-20D99BBFEBAD

if not self.exists():
return []
return self
Copy link
Owner Author

Choose a reason for hiding this comment

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

Need to file a bug report about this so I can mention it in the release notes.

@simonw simonw merged commit 6155da7 into main Aug 10, 2021
@simonw simonw deleted the autodoc branch August 10, 2021 23:09
simonw added a commit that referenced this pull request Aug 10, 2021
simonw added a commit that referenced this pull request Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant