diff --git a/.gitignore b/.gitignore index 2a0669d11a4..7fea4f3be3d 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,9 @@ __pycache__ _build rtd_docs/generated +# API docs +docs/api_docs + # swap files *.swp diff --git a/check/nbformat b/check/nbformat index 19c6dcf6957..2a123c9ffb8 100755 --- a/check/nbformat +++ b/check/nbformat @@ -29,7 +29,7 @@ cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$(git rev-parse --show-toplevel)" # Install a pinned version of tf-docs -TF_DOCS_COMMIT=ec2bfadbec885fc40268b4193d8b87648ab45791 +TF_DOCS_COMMIT=b3dc8a922d8bdc6e998a8ad4f4953359dc6e576a TF_DOCS_INSTALLED=$(pip list | grep -c $TF_DOCS_COMMIT) if [ "$TF_DOCS_INSTALLED" != "1" ]; then diff --git a/cirq/_doc.py b/cirq/_doc.py index 1c370da239c..52043964b01 100644 --- a/cirq/_doc.py +++ b/cirq/_doc.py @@ -54,3 +54,33 @@ def document(value: Any, doc_string: str = ''): # print(traceback.format_stack(limit=2)[0]) pass return value + + +# This is based on +# https://github.com/tensorflow/docs/commit/129e54b1a1dc2c2c82ad94bc81e986c7c2be3d6a#diff-85111596b523b2940651a8856939755c8531d470948895c7133deb6a537bc889R295-R324 + +_DOC_PRIVATE = "_tf_docs_doc_private" + + +def doc_private(obj): + """A decorator: Generates docs for private methods/functions. + + For example: + ``` + class Try: + @doc_private + def _private(self): + ... + ``` + As a rule of thumb, private (beginning with `_`) methods/functions are + not documented. This decorator allows to force document a private + method/function. + + Args: + obj: The class-attribute to force the documentation for. + Returns: + obj + """ + + setattr(obj, _DOC_PRIVATE, None) + return obj diff --git a/cirq/experiments/qubit_characterizations.py b/cirq/experiments/qubit_characterizations.py index 22fadd33f55..75e06b3ff36 100644 --- a/cirq/experiments/qubit_characterizations.py +++ b/cirq/experiments/qubit_characterizations.py @@ -445,34 +445,26 @@ def two_qubit_state_tomography(sampler: work.Sampler, The state probabilities $P_{00}, P_{01}, P_{10}$ thus obtained contribute to the following linear equations (setting $c_{00} = 1$): - $$ - c_{03} + c_{30} + c_{33} = 4*P_{00} - 1 - $$ - - $$ - -c_{03} + c_{30} - c_{33} = 4*P_{01} - 1 - $$ - - $$ - c_{03} - c_{30} - c_{33} = 4*P_{10} - 1 - $$ + $$ + \begin{align} + c_{03} + c_{30} + c_{33} &= 4*P_{00} - 1 \\ + -c_{03} + c_{30} - c_{33} &= 4*P_{01} - 1 \\ + c_{03} - c_{30} - c_{33} &= 4*P_{10} - 1 + \end{align} + $$ And if a Y/2 rotation is applied to the first qubit and a X/2 rotation is applied to the second qubit before measurement, the measurement operators are $(I -/+ \sigma_x) \bigotimes (I +/- \sigma_y)$. The probabilities obtained instead contribute to the following linear equations: - $$ - c_{02} - c_{10} - c_{12} = 4*P_{00} - 1 - $$ - - $$ - -c_{02} - c_{10} + c_{12} = 4*P_{01} - 1 - $$ - - $$ - c_{02} + c_{10} + c_{12} = 4*P_{10} - 1 - $$ + $$ + \begin{align} + c_{02} - c_{10} - c_{12} &= 4*P_{00} - 1 \\ + -c_{02} - c_{10} + c_{12} &= 4*P_{01} - 1 \\ + c_{02} + c_{10} + c_{12} &= 4*P_{10} - 1 + \end{align} + $$ Note that this set of equations has the same form as the first set under the transformation $c_{03}$ <-> $c_{02}, c_{30}$ <-> $-c_{10}$ and diff --git a/cirq/protocols/act_on_protocol.py b/cirq/protocols/act_on_protocol.py index 71fec022cf1..36493ed8b1f 100644 --- a/cirq/protocols/act_on_protocol.py +++ b/cirq/protocols/act_on_protocol.py @@ -17,7 +17,7 @@ from typing_extensions import Protocol -from cirq._doc import document +from cirq._doc import doc_private from cirq.type_workarounds import NotImplementedType if TYPE_CHECKING: @@ -27,7 +27,7 @@ class SupportsActOn(Protocol): """An object that explicitly specifies how to act on simulator states.""" - @document + @doc_private def _act_on_(self, args: Any) -> Union[NotImplementedType, bool]: """Applies an action to the given argument, if it is a supported type. diff --git a/cirq/protocols/apply_channel_protocol.py b/cirq/protocols/apply_channel_protocol.py index f1065c545ec..b0ebffc130d 100644 --- a/cirq/protocols/apply_channel_protocol.py +++ b/cirq/protocols/apply_channel_protocol.py @@ -19,6 +19,7 @@ from typing_extensions import Protocol from cirq import linalg +from cirq._doc import doc_private from cirq.protocols.apply_unitary_protocol import ( apply_unitary, ApplyUnitaryArgs, @@ -115,6 +116,7 @@ def __init__(self, target_tensor: np.ndarray, out_buffer: np.ndarray, class SupportsApplyChannel(Protocol): """An object that can efficiently implement a channel.""" + @doc_private def _apply_channel_(self, args: ApplyChannelArgs ) -> Union[np.ndarray, None, NotImplementedType]: """Efficiently applies a channel. diff --git a/cirq/protocols/apply_mixture_protocol.py b/cirq/protocols/apply_mixture_protocol.py index b537f968dad..0f05a352078 100644 --- a/cirq/protocols/apply_mixture_protocol.py +++ b/cirq/protocols/apply_mixture_protocol.py @@ -19,6 +19,7 @@ from typing_extensions import Protocol from cirq import linalg +from cirq._doc import doc_private from cirq.protocols.apply_unitary_protocol import ( apply_unitary, ApplyUnitaryArgs, @@ -112,6 +113,7 @@ def __init__(self, class SupportsApplyMixture(Protocol): """An object that can efficiently implement a mixture.""" + @doc_private def _apply_mixture_(self, args: ApplyMixtureArgs ) -> Union[np.ndarray, None, NotImplementedType]: """Efficiently applies a mixture. diff --git a/cirq/protocols/apply_unitary_protocol.py b/cirq/protocols/apply_unitary_protocol.py index 0ed9addfbe2..a1beface48b 100644 --- a/cirq/protocols/apply_unitary_protocol.py +++ b/cirq/protocols/apply_unitary_protocol.py @@ -29,6 +29,7 @@ from typing_extensions import Protocol from cirq import linalg, qis +from cirq._doc import doc_private from cirq.protocols import qid_shape_protocol from cirq.protocols.decompose_protocol import ( _try_decompose_into_operations_and_qubits,) @@ -219,6 +220,7 @@ def subspace_index(self, class SupportsConsistentApplyUnitary(Protocol): """An object that can be efficiently left-multiplied into tensors.""" + @doc_private def _apply_unitary_(self, args: ApplyUnitaryArgs ) -> Union[np.ndarray, None, NotImplementedType]: """Left-multiplies a unitary effect onto a tensor with good performance. diff --git a/cirq/protocols/approximate_equality_protocol.py b/cirq/protocols/approximate_equality_protocol.py index 8dae0e824e7..848a003399f 100644 --- a/cirq/protocols/approximate_equality_protocol.py +++ b/cirq/protocols/approximate_equality_protocol.py @@ -22,10 +22,13 @@ from typing_extensions import Protocol +from cirq._doc import doc_private + class SupportsApproximateEquality(Protocol): """Object which can be compared approximately.""" + @doc_private def _approx_eq_(self, other: Any, *, atol: Union[int, float]) -> bool: """Approximate comparator. diff --git a/cirq/protocols/channel.py b/cirq/protocols/channel.py index b4e411132d9..29e8b33cdf8 100644 --- a/cirq/protocols/channel.py +++ b/cirq/protocols/channel.py @@ -20,6 +20,7 @@ import numpy as np from typing_extensions import Protocol +from cirq._doc import doc_private from cirq.protocols.decompose_protocol import ( _try_decompose_into_operations_and_qubits,) from cirq.protocols.mixture_protocol import has_mixture @@ -42,6 +43,7 @@ class SupportsChannel(Protocol): """An object that may be describable as a quantum channel.""" + @doc_private def _channel_(self) -> Union[Sequence[np.ndarray], NotImplementedType]: r"""A list of matrices describing the quantum channel. @@ -76,6 +78,8 @@ def _channel_(self) -> Union[Sequence[np.ndarray], NotImplementedType]: A list of matrices describing the channel (Kraus operators), or NotImplemented if there is no such matrix. """ + + @doc_private def _has_channel_(self) -> bool: """Whether this value has a channel representation. diff --git a/cirq/protocols/circuit_diagram_info_protocol.py b/cirq/protocols/circuit_diagram_info_protocol.py index 71d1f90f386..a118e67ea74 100644 --- a/cirq/protocols/circuit_diagram_info_protocol.py +++ b/cirq/protocols/circuit_diagram_info_protocol.py @@ -21,6 +21,7 @@ from typing_extensions import Protocol from cirq import protocols, value +from cirq._doc import doc_private if TYPE_CHECKING: import cirq @@ -304,6 +305,7 @@ def with_args(self, **kwargs): class SupportsCircuitDiagramInfo(Protocol): """A diagrammable operation on qubits.""" + @doc_private def _circuit_diagram_info_( self, args: CircuitDiagramInfoArgs ) -> Union[str, Iterable[str], CircuitDiagramInfo]: diff --git a/cirq/protocols/commutes_protocol.py b/cirq/protocols/commutes_protocol.py index 0802a2c5a43..b4a6e5cf5d0 100644 --- a/cirq/protocols/commutes_protocol.py +++ b/cirq/protocols/commutes_protocol.py @@ -16,11 +16,10 @@ from typing import Any, TypeVar, Union import numpy as np - from typing_extensions import Protocol from cirq import linalg, ops -from cirq._doc import document +from cirq._doc import doc_private from cirq.protocols import qid_shape_protocol, unitary_protocol from cirq.type_workarounds import NotImplementedType @@ -36,7 +35,7 @@ class SupportsCommutes(Protocol): """An object that can determine commutation relationships vs others.""" - @document + @doc_private def _commutes_(self, other: Any, atol: float) -> Union[None, bool, NotImplementedType]: r"""Determines if this object commutes with the other object. diff --git a/cirq/protocols/decompose_protocol.py b/cirq/protocols/decompose_protocol.py index 7c13614223f..3564d106ce2 100644 --- a/cirq/protocols/decompose_protocol.py +++ b/cirq/protocols/decompose_protocol.py @@ -27,9 +27,11 @@ Union, ) from collections import defaultdict + from typing_extensions import Protocol from cirq import devices, ops +from cirq._doc import doc_private from cirq.protocols import qid_shape_protocol from cirq.type_workarounds import NotImplementedType @@ -92,6 +94,7 @@ class SupportsDecompose(Protocol): raise a caller-provided error. """ + @doc_private def _decompose_(self) -> DecomposeResult: pass diff --git a/cirq/protocols/equal_up_to_global_phase_protocol.py b/cirq/protocols/equal_up_to_global_phase_protocol.py index 898569fe35f..3656e77bbd5 100644 --- a/cirq/protocols/equal_up_to_global_phase_protocol.py +++ b/cirq/protocols/equal_up_to_global_phase_protocol.py @@ -12,21 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. -from collections.abc import Iterable import numbers +from collections.abc import Iterable from typing import Any, Union + import numpy as np from typing_extensions import Protocol from cirq import linalg -from cirq._doc import document +from cirq._doc import doc_private from cirq.protocols.approximate_equality_protocol import approx_eq class SupportsEqualUpToGlobalPhase(Protocol): """Object which can be compared for equality mod global phase.""" - @document + @doc_private def _equal_up_to_global_phase_(self, other: Any, *, atol: Union[int, float]) -> bool: """Approximate comparator. diff --git a/cirq/protocols/has_unitary_protocol.py b/cirq/protocols/has_unitary_protocol.py index 048fb6959d3..edc3a3f0ca9 100644 --- a/cirq/protocols/has_unitary_protocol.py +++ b/cirq/protocols/has_unitary_protocol.py @@ -13,7 +13,6 @@ # limitations under the License. from typing import ( - TYPE_CHECKING, Any, TypeVar, Optional, @@ -22,15 +21,12 @@ import numpy as np from typing_extensions import Protocol -from cirq._doc import document +from cirq import qis +from cirq._doc import doc_private from cirq.protocols import qid_shape_protocol from cirq.protocols.apply_unitary_protocol import ApplyUnitaryArgs from cirq.protocols.decompose_protocol import ( _try_decompose_into_operations_and_qubits,) -from cirq import qis - -if TYPE_CHECKING: - import cirq TDefault = TypeVar('TDefault') @@ -38,7 +34,7 @@ class SupportsExplicitHasUnitary(Protocol): """An object that explicitly specifies whether it has a unitary effect.""" - @document + @doc_private def _has_unitary_(self) -> bool: """Determines whether the receiver has a unitary effect. diff --git a/cirq/protocols/json_serialization.py b/cirq/protocols/json_serialization.py index d395dcb9d03..9ea5aa690cb 100644 --- a/cirq/protocols/json_serialization.py +++ b/cirq/protocols/json_serialization.py @@ -35,6 +35,7 @@ import sympy from typing_extensions import Protocol +from cirq._doc import doc_private from cirq.ops import raw_types # Tells mypy that the raw_types module exists from cirq.type_workarounds import NotImplementedType @@ -245,6 +246,7 @@ class SupportsJSON(Protocol): constructor. """ + @doc_private def _json_dict_(self) -> Union[None, NotImplementedType, Dict[Any, Any]]: pass diff --git a/cirq/protocols/measurement_key_protocol.py b/cirq/protocols/measurement_key_protocol.py index a8e91f32778..7284a5398a9 100644 --- a/cirq/protocols/measurement_key_protocol.py +++ b/cirq/protocols/measurement_key_protocol.py @@ -17,12 +17,10 @@ from typing_extensions import Protocol -from cirq._doc import document - +from cirq._doc import doc_private from cirq.protocols.decompose_protocol import \ _try_decompose_into_operations_and_qubits - # This is a special indicator value used by the inverse method to determine # whether or not the caller provided a 'default' argument. RaiseTypeErrorIfNotProvided = ([],) # type: Any @@ -49,7 +47,7 @@ class SupportsMeasurementKey(Protocol): conditional on the measurement outcome being $k$. """ - @document + @doc_private def _measurement_key_(self) -> str: """Return the key that will be used to identify this measurement. @@ -58,7 +56,7 @@ def _measurement_key_(self) -> str: will be stored. """ - @document + @doc_private def _measurement_keys_(self) -> Iterable[str]: """Return the keys for measurements performed by the receiving object. diff --git a/cirq/protocols/mixture_protocol.py b/cirq/protocols/mixture_protocol.py index 52168126536..9cf77c9b5b5 100644 --- a/cirq/protocols/mixture_protocol.py +++ b/cirq/protocols/mixture_protocol.py @@ -19,11 +19,10 @@ from typing_extensions import Protocol from cirq._compat import deprecated -from cirq._doc import document +from cirq._doc import doc_private from cirq.protocols.decompose_protocol import \ _try_decompose_into_operations_and_qubits from cirq.protocols.has_unitary_protocol import has_unitary - from cirq.type_workarounds import NotImplementedType # This is a special indicator value used by the inverse method to determine @@ -35,7 +34,7 @@ class SupportsMixture(Protocol): """An object that decomposes into a probability distribution of unitaries. """ - @document + @doc_private def _mixture_(self ) -> Union[Sequence[Tuple[float, Any]], NotImplementedType]: """Decompose into a probability distribution of unitaries. @@ -53,7 +52,7 @@ def _mixture_(self A list of (probability, unitary) pairs. """ - @document + @doc_private def _has_mixture_(self) -> bool: """Whether this value has a mixture representation. diff --git a/cirq/protocols/pauli_expansion_protocol.py b/cirq/protocols/pauli_expansion_protocol.py index d5323a88fb4..23b57830dd0 100644 --- a/cirq/protocols/pauli_expansion_protocol.py +++ b/cirq/protocols/pauli_expansion_protocol.py @@ -17,6 +17,7 @@ from typing_extensions import Protocol from cirq import value +from cirq._doc import doc_private from cirq.linalg import operator_spaces from cirq.protocols import qid_shape_protocol, unitary_protocol @@ -29,6 +30,7 @@ class SupportsPauliExpansion(Protocol): """An object that knows its expansion in the Pauli basis.""" + @doc_private def _pauli_expansion_(self) -> value.LinearDict[str]: """Efficiently obtains expansion of self in the Pauli basis. diff --git a/cirq/protocols/phase_protocol.py b/cirq/protocols/phase_protocol.py index f7b6310290e..e1f51bd63ba 100644 --- a/cirq/protocols/phase_protocol.py +++ b/cirq/protocols/phase_protocol.py @@ -19,7 +19,7 @@ # This is a special value to indicate that a type error should be returned. # This is used within phase_by to raise an error if no underlying # implementation of _phase_by_ exists. -from cirq._doc import document +from cirq._doc import doc_private RaiseTypeErrorIfNotProvided = ([],) # type: Any @@ -29,7 +29,7 @@ class SupportsPhase(Protocol): """An effect that can be phased around the Z axis of target qubits.""" - @document + @doc_private def _phase_by_(self: Any, phase_turns: float, qubit_index: int): """Returns a phased version of the effect. diff --git a/cirq/protocols/qasm.py b/cirq/protocols/qasm.py index 7f8f1d0f530..e9a45a40b5b 100644 --- a/cirq/protocols/qasm.py +++ b/cirq/protocols/qasm.py @@ -19,7 +19,7 @@ from typing_extensions import Protocol from cirq import ops -from cirq._doc import document +from cirq._doc import doc_private from cirq.type_workarounds import NotImplementedType if TYPE_CHECKING: @@ -82,7 +82,7 @@ class SupportsQasm(Protocol): will be used instead. """ - @document + @doc_private def _qasm_(self) -> Union[None, NotImplementedType, str]: pass @@ -95,7 +95,7 @@ class SupportsQasmWithArgs(Protocol): will be used instead. """ - @document + @doc_private def _qasm_(self, args: QasmArgs) -> Union[None, NotImplementedType, str]: pass @@ -109,7 +109,7 @@ class SupportsQasmWithArgsAndQubits(Protocol): will be used instead. """ - @document + @doc_private def _qasm_(self, qubits: Tuple['cirq.Qid'], args: QasmArgs) -> Union[None, NotImplementedType, str]: diff --git a/cirq/protocols/qid_shape_protocol.py b/cirq/protocols/qid_shape_protocol.py index c6c5ce05827..0137aed6257 100644 --- a/cirq/protocols/qid_shape_protocol.py +++ b/cirq/protocols/qid_shape_protocol.py @@ -12,17 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import TYPE_CHECKING, Any, Sequence, Tuple, TypeVar, Union +from typing import Any, Sequence, Tuple, TypeVar, Union from typing_extensions import Protocol from cirq import ops -from cirq._doc import document +from cirq._doc import document, doc_private from cirq.type_workarounds import NotImplementedType -if TYPE_CHECKING: - import cirq - # This is a special indicator value used by the methods to determine whether or # not the caller provided a 'default' argument. It must be of type # Tuple[int, ...] to ensure the method has the correct type signature in that @@ -39,7 +36,7 @@ class SupportsExplicitQidShape(Protocol): """A unitary, channel, mixture or other object that operates on a known number qubits/qudits/qids, each with a specific number of quantum levels.""" - @document + @doc_private def _qid_shape_(self) -> Union[Tuple[int, ...], NotImplementedType]: """A tuple specifying the number of quantum levels of each qid this object operates on, e.g. (2, 2, 2) for a three-qubit gate. diff --git a/cirq/protocols/resolve_parameters.py b/cirq/protocols/resolve_parameters.py index 70622e74560..c287c7c0748 100644 --- a/cirq/protocols/resolve_parameters.py +++ b/cirq/protocols/resolve_parameters.py @@ -14,12 +14,12 @@ import numbers from typing import AbstractSet, Any, TypeVar, TYPE_CHECKING -from typing_extensions import Protocol import sympy +from typing_extensions import Protocol from cirq import study -from cirq._doc import document +from cirq._doc import doc_private if TYPE_CHECKING: import cirq @@ -31,13 +31,13 @@ class SupportsParameterization(Protocol): """An object that can be parameterized by Symbols and resolved via a ParamResolver""" - @document + @doc_private def _is_parameterized_(self: Any) -> bool: """Whether the object is parameterized by any Symbols that require resolution. Returns True if the object has any unresolved Symbols and False otherwise.""" - @document + @doc_private def _parameter_names_(self: Any) -> AbstractSet[str]: """Returns a collection of string names of parameters that require resolution. If _is_parameterized_ is False, the collection is empty. @@ -46,7 +46,7 @@ def _parameter_names_(self: Any) -> AbstractSet[str]: need to be evaluated, but no free symbols. """ - @document + @doc_private def _resolve_parameters_(self: Any, param_resolver: 'cirq.ParamResolver'): """Resolve the parameters in the effect.""" diff --git a/cirq/protocols/trace_distance_bound.py b/cirq/protocols/trace_distance_bound.py index c2909c5de7d..b9b9a4763a4 100644 --- a/cirq/protocols/trace_distance_bound.py +++ b/cirq/protocols/trace_distance_bound.py @@ -13,13 +13,13 @@ # limitations under the License. from typing import Any, TypeVar, Optional, Sequence + import numpy as np from typing_extensions import Protocol -from cirq._doc import document +from cirq._doc import doc_private from cirq.protocols import unitary_protocol - TDefault = TypeVar('TDefault') @@ -32,7 +32,7 @@ class SupportsTraceDistanceBound(Protocol): negligible. """ - @document + @doc_private def _trace_distance_bound_(self) -> float: """A maximum on the trace distance between `val`'s input and output. diff --git a/cirq/protocols/unitary_protocol.py b/cirq/protocols/unitary_protocol.py index ee08545c593..2cf1be3683a 100644 --- a/cirq/protocols/unitary_protocol.py +++ b/cirq/protocols/unitary_protocol.py @@ -13,7 +13,6 @@ # limitations under the License. from typing import ( - TYPE_CHECKING, Any, TypeVar, Union, @@ -24,7 +23,7 @@ from typing_extensions import Protocol from cirq import qis -from cirq._doc import document +from cirq._doc import doc_private from cirq.protocols import qid_shape_protocol from cirq.protocols.apply_unitary_protocol import ( ApplyUnitaryArgs, @@ -34,9 +33,6 @@ _try_decompose_into_operations_and_qubits,) from cirq.type_workarounds import NotImplementedType -if TYPE_CHECKING: - import cirq - # This is a special indicator value used by the unitary method to determine # whether or not the caller provided a 'default' argument. It must be of type # np.ndarray to ensure the method has the correct type signature in that case. @@ -50,7 +46,7 @@ class SupportsUnitary(Protocol): """An object that may be describable by a unitary matrix.""" - @document + @doc_private def _unitary_(self) -> Union[np.ndarray, NotImplementedType]: """A unitary matrix describing this value, e.g. the matrix of a gate. @@ -75,7 +71,7 @@ def _unitary_(self) -> Union[np.ndarray, NotImplementedType]: is no such matrix. """ - @document + @doc_private def _has_unitary_(self) -> bool: """Whether this value has a unitary matrix representation. diff --git a/dev_tools/docs/Dockerfile b/dev_tools/docs/Dockerfile new file mode 100644 index 00000000000..f94bfce9317 --- /dev/null +++ b/dev_tools/docs/Dockerfile @@ -0,0 +1,44 @@ +# Copyright 2020 The Cirq Developers +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +######################################################################################## +# This is a Dockerfile to preview the api-docs generation +# +# Usage: +# docker build -t cirq-api-docs -f dev_tools/docs/Dockerfile . +# docker run -d --name=cirq-api-docs -p 8080:8080 cirq-api-docs +# To stop: +# docker kill cirq-api-docs && docker rm cirq-api-docs +# +# You can then preview the site at http://localhost:8080 +# Eventually this might become the basis of an automated preview service for each +# PR. +######################################################################################## + +FROM nikolaik/python-nodejs:python3.7-nodejs14 + +RUN pip install -U git+https://github.com/tensorflow/docs && npm i -g markserv + +RUN mkdir /cirq + +WORKDIR /cirq + +ADD requirements.txt . +RUN pip install -r requirements.txt + +ADD . /cirq +RUN PYTHONPATH=/cirq python3 dev_tools/docs/build_api_docs.py --output_dir=docs/api_docs + +WORKDIR /cirq/docs/api_docs +CMD ["markserv", "-b=false", "-p=8080", "-a=0.0.0.0"] \ No newline at end of file