Skip to content

Commit

Permalink
Fix methods missing from doc strings (#3048)
Browse files Browse the repository at this point in the history
  • Loading branch information
dabacon authored and dstrain115 committed Jun 3, 2020
1 parent 0567d33 commit 6dd7484
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
6 changes: 3 additions & 3 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ Unitary effects that can be applied to one or more qubits.
cirq.givens
cirq.identity_each
cirq.riswap
cirq.CCNotPowGate
.. autoclass:: cirq.CCNotPowGate
cirq.CCXPowGate
cirq.CCZPowGate
cirq.CNotPowGate
.. autoclass:: cirq.CNotPowGate
cirq.CSwapGate
cirq.CXPowGate
cirq.CZPowGate
Expand Down Expand Up @@ -251,7 +251,7 @@ results.
cirq.ExpressionMap
cirq.Linspace
cirq.ListSweep
cirq.ParamDictType
.. autoclass:: cirq.ParamDictType
cirq.ParamResolver
cirq.ParamResolverOrSimilarType
cirq.PauliSumCollector
Expand Down
9 changes: 8 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,14 @@ def autodoc_skip_member(
) -> bool:
"""Public members already kept. Also include members marked as documented.
"""
return id(obj) not in _doc.RECORDED_CONST_DOCS
# Never skip if explicitly whitelisted.
if id(obj) in _doc.RECORDED_CONST_DOCS:
return False
# Skip all private methods.
if name.startswith('_'):
return True
# Fallback to default.
return skip


def autodoc_process(app, what: str, name: str, obj: Any, options,
Expand Down
9 changes: 5 additions & 4 deletions docs/docs_coverage_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import inspect
from pathlib import Path
import pathlib
import re
from typing import Set, Dict, Tuple, Any, List

import cirq
Expand Down Expand Up @@ -43,14 +44,14 @@ def _api_rst_fullnames_per_section() -> List[List[str]]:
result: List[List[str]] = []
section: List[str] = []
seen: Set[str] = set()
with open(Path(__file__).parent / 'api.rst', mode='r') as f:
with open(pathlib.Path(__file__).parent / 'api.rst', mode='r') as f:
for line in f.readlines():
if line.strip() == '.. autosummary::':
if section:
result.append(section)
section = []
elif line.startswith(' cirq.'):
fullname = line.strip()
elif ' cirq.' in line or ' .. autoclass:: cirq.' in line:
fullname = line[line.find('cirq'):].strip()
if fullname in seen:
# coverage: ignore
raise ValueError(f'{fullname} appears twice in api.rst')
Expand Down

0 comments on commit 6dd7484

Please sign in to comment.