Skip to content

Commit

Permalink
docs: update build procedure and fix warning
Browse files Browse the repository at this point in the history
Build api docs in conf.py so it is all in one place for readthedocs
to make use of.

Signed-off-by: Sergio Schvezov <sergio.schvezov@canonical.com>
  • Loading branch information
sergiusens committed Oct 14, 2021
1 parent df95bcf commit 7d0460a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ python:
install:
- requirements: requirements.txt
- requirements: requirements-dev.txt
- method: pip
path: .
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ coverage: ## Run pytest with coverage report.
docs: ## Generate documentation.
rm -f docs/craft_store.rst
rm -f docs/modules.rst
sphinx-apidoc -o docs/ craft_store --no-toc --ext-githubpages
$(MAKE) -C docs clean
$(MAKE) -C docs html

Expand Down
11 changes: 4 additions & 7 deletions craft_store/store_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,17 @@

import base64
import json
from typing import TYPE_CHECKING, Any, Dict, Sequence
from typing import Any, Dict, Sequence
from urllib.parse import urlparse

import requests
from macaroonbakery import bakery, httpbakery
from pymacaroons.serializers import json_serializer

from . import errors
from . import endpoints, errors
from .auth import Auth
from .http_client import HTTPClient

if TYPE_CHECKING:
from . import endpoints


def _macaroon_to_json_string(macaroon) -> str:
return macaroon.serialize(json_serializer.JsonSerializer())
Expand Down Expand Up @@ -78,14 +75,14 @@ def __init__(
self,
*,
base_url: str,
endpoints: "endpoints.Endpoints",
endpoints: endpoints.Endpoints,
application_name: str,
user_agent: str,
) -> None:
"""Initialize the Store Client.
:param base_url: the base url of the API endpoint.
:param endpoints: :data:`endpoints.CHARMHUB` or :data:`endpoints.SNAP_STORE`.
:param endpoints: :data:`.endpoints.CHARMHUB` or :data:`.endpoints.SNAP_STORE`.
:param application_name: the name application using this class, used for the keyring.
:param user_agent: User-Agent header to use for HTTP(s) requests.
"""
Expand Down
15 changes: 15 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,18 @@

# Enable support for google-style instance attributes.
napoleon_use_ivar = True


def run_apidoc(_):
from sphinx.ext.apidoc import main
import os
import sys

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
cur_dir = os.path.abspath(os.path.dirname(__file__))
module = os.path.join(cur_dir, "..", "craft_store")
main(["-e", "-o", cur_dir, module, "--no-toc", "--force"])


def setup(app):
app.connect("builder-inited", run_apidoc)

0 comments on commit 7d0460a

Please sign in to comment.