Skip to content

Commit

Permalink
Data Labeling: Add nox session docs, reorder methods (via synth). (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored and busunkim96 committed May 9, 2019
1 parent db583fc commit 4e6feb5
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 35 deletions.
1 change: 1 addition & 0 deletions datalabeling/docs/README.rst
42 changes: 38 additions & 4 deletions datalabeling/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'
needs_sphinx = "1.6.3"

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
Expand All @@ -36,6 +36,7 @@
"sphinx.ext.intersphinx",
"sphinx.ext.coverage",
"sphinx.ext.napoleon",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
]

Expand All @@ -47,10 +48,14 @@
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# Allow markdown includes (so releases.md can include CHANGLEOG.md)
# http://www.sphinx-doc.org/en/master/markdown.html
source_parsers = {".md": "recommonmark.parser.CommonMarkParser"}

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = ".rst"
source_suffix = [".rst", ".md"]

# The encoding of source files.
# source_encoding = 'utf-8-sig'
Expand Down Expand Up @@ -120,12 +125,20 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = "sphinx_rtd_theme"
html_theme = "alabaster"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
# html_theme_options = {}
html_theme_options = {
"description": "Google Cloud Client Libraries for Python",
"github_user": "googleapis",
"github_repo": "google-cloud-python",
"github_banner": True,
"font_family": "'Roboto', Georgia, sans",
"head_font_family": "'Roboto', Georgia, serif",
"code_font_family": "'Roboto Mono', 'Consolas', monospace",
}

# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []
Expand Down Expand Up @@ -214,6 +227,17 @@
# Output file base name for HTML help builder.
htmlhelp_basename = "google-cloud-datalabeling-doc"

# -- Options for warnings ------------------------------------------------------

suppress_warnings = [
# Temporarily suppress this to avoid "more than one target found for
# cross-reference" warning, which are intractable for us to avoid while in
# a mono-repo.
# See https://github.com/sphinx-doc/sphinx/blob
# /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843
"ref.python"
]

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
Expand Down Expand Up @@ -310,6 +334,16 @@
intersphinx_mapping = {
"python": ("http://python.readthedocs.org/en/latest/", None),
"gax": ("https://gax-python.readthedocs.org/en/latest/", None),
"google-auth": ("https://google-auth.readthedocs.io/en/stable", None),
"google-gax": ("https://gax-python.readthedocs.io/en/latest/", None),
"google.api_core": (
"https://googleapis.github.io/google-cloud-python/latest",
None,
),
"grpc": ("https://grpc.io/grpc/python/", None),
"requests": ("http://docs.python-requests.org/en/master/", None),
"fastavro": ("https://fastavro.readthedocs.io/en/stable/", None),
"pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None),
}

# Napoleon settings
Expand Down
13 changes: 11 additions & 2 deletions datalabeling/docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. include:: /../datalabeling/README.rst
.. include:: README.rst

Api Reference
-------------
Expand All @@ -7,4 +7,13 @@ Api Reference

gapic/v1beta1/api
gapic/v1beta1/types
changelog

Changelog
---------

For a list of all ``google-cloud-datalabeling`` releases:

.. toctree::
:maxdepth: 2

changelog
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,13 @@ def from_service_account_file(cls, filename, *args, **kwargs):
from_service_account_json = from_service_account_file

@classmethod
def project_path(cls, project):
"""Return a fully-qualified project string."""
def annotated_dataset_path(cls, project, dataset, annotated_dataset):
"""Return a fully-qualified annotated_dataset string."""
return google.api_core.path_template.expand(
"projects/{project}", project=project
"projects/{project}/datasets/{dataset}/annotatedDatasets/{annotated_dataset}",
project=project,
dataset=dataset,
annotated_dataset=annotated_dataset,
)

@classmethod
Expand All @@ -99,20 +102,20 @@ def annotation_spec_set_path(cls, project, annotation_spec_set):
)

@classmethod
def dataset_path(cls, project, dataset):
"""Return a fully-qualified dataset string."""
def data_item_path(cls, project, dataset, data_item):
"""Return a fully-qualified data_item string."""
return google.api_core.path_template.expand(
"projects/{project}/datasets/{dataset}", project=project, dataset=dataset
"projects/{project}/datasets/{dataset}/dataItems/{data_item}",
project=project,
dataset=dataset,
data_item=data_item,
)

@classmethod
def annotated_dataset_path(cls, project, dataset, annotated_dataset):
"""Return a fully-qualified annotated_dataset string."""
def dataset_path(cls, project, dataset):
"""Return a fully-qualified dataset string."""
return google.api_core.path_template.expand(
"projects/{project}/datasets/{dataset}/annotatedDatasets/{annotated_dataset}",
project=project,
dataset=dataset,
annotated_dataset=annotated_dataset,
"projects/{project}/datasets/{dataset}", project=project, dataset=dataset
)

@classmethod
Expand All @@ -126,16 +129,6 @@ def example_path(cls, project, dataset, annotated_dataset, example):
example=example,
)

@classmethod
def data_item_path(cls, project, dataset, data_item):
"""Return a fully-qualified data_item string."""
return google.api_core.path_template.expand(
"projects/{project}/datasets/{dataset}/dataItems/{data_item}",
project=project,
dataset=dataset,
data_item=data_item,
)

@classmethod
def instruction_path(cls, project, instruction):
"""Return a fully-qualified instruction string."""
Expand All @@ -145,6 +138,13 @@ def instruction_path(cls, project, instruction):
instruction=instruction,
)

@classmethod
def project_path(cls, project):
"""Return a fully-qualified project string."""
return google.api_core.path_template.expand(
"projects/{project}", project=project
)

def __init__(
self,
transport=None,
Expand Down
20 changes: 20 additions & 0 deletions datalabeling/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from __future__ import absolute_import
import os
import shutil

import nox

Expand Down Expand Up @@ -138,3 +139,22 @@ def cover(session):
session.run("coverage", "report", "--show-missing", "--fail-under=80")

session.run("coverage", "erase")

@nox.session(python="3.7")
def docs(session):
"""Build the docs for this library."""

session.install('-e', '.')
session.install('sphinx', 'alabaster', 'recommonmark')

shutil.rmtree(os.path.join('docs', '_build'), ignore_errors=True)
session.run(
'sphinx-build',
'-W', # warnings as errors
'-T', # show full traceback on exception
'-N', # no colors
'-b', 'html',
'-d', os.path.join('docs', '_build', 'doctrees', ''),
os.path.join('docs', ''),
os.path.join('docs', '_build', 'html', ''),
)
14 changes: 7 additions & 7 deletions datalabeling/synth.metadata
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"updateTime": "2019-04-01T20:28:56.710893Z",
"updateTime": "2019-05-02T16:41:45.804157Z",
"sources": [
{
"generator": {
"name": "artman",
"version": "0.16.22",
"dockerImage": "googleapis/artman@sha256:e7f9554322a8aa1416c122c918fdc4cdec8cfe816f027fc948dec0be7edef320"
"version": "0.17.1",
"dockerImage": "googleapis/artman@sha256:a40ca4dd4ef031c0ded4df4909ffdf7b3f20d29b23e682ef991eb60ba0ca6025"
}
},
{
"git": {
"name": "googleapis",
"remote": "git@github.com:googleapis/googleapis.git",
"sha": "62baea94d3760d9a58064a6e6ee9b99eff2a608e",
"internalRef": "241370948"
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "dd42335a9a8613072bef9cbda2725e84631d7043",
"internalRef": "246232940"
}
},
{
"template": {
"name": "python_library",
"origin": "synthtool.gcp",
"version": "2019.2.26"
"version": "2019.4.10"
}
}
],
Expand Down

0 comments on commit 4e6feb5

Please sign in to comment.