Skip to content

Commit

Permalink
Added Glossary to docs with metadata definition
Browse files Browse the repository at this point in the history
  • Loading branch information
kpayson64 committed Jul 12, 2016
1 parent 76c9296 commit f7f47a6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 18 deletions.
23 changes: 23 additions & 0 deletions src/python/grpcio/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@
html_theme = 'sphinx_rtd_theme'
"""

API_GLOSSARY = """
Glossary
================
.. glossary::
metadatum
A key-value pair included in the HTTP header. It is a
2-tuple where the first entry is the key and the
second is the value, i.e. (key, value). The metadata key is an ASCII str,
and must be a valid HTTP header name. The metadata value can be
either a valid HTTP ASCII str, or bytes. If bytes are provided,
the key must end with '-bin', i.e.
``('binary-metadata-bin', b'\\x00\\xFF')``
metadata
A sequence of metadatum.
"""


class CommandError(Exception):
"""Simple exception class for GRPC custom commands."""
Expand Down Expand Up @@ -131,6 +151,9 @@ def run(self):
conf_filepath = os.path.join('doc', 'src', 'conf.py')
with open(conf_filepath, 'a') as conf_file:
conf_file.write(CONF_PY_ADDENDUM)
glossary_filepath = os.path.join('doc', 'src', 'grpc.rst')
with open(glossary_filepath, 'a') as glossary_filepath:
glossary_filepath.write(API_GLOSSARY)
sphinx.main(['', os.path.join('doc', 'src'), os.path.join('doc', 'build')])


Expand Down
33 changes: 15 additions & 18 deletions src/python/grpcio/grpc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def initial_metadata(self):
This method blocks until the value is available.
Returns:
The initial metadata as a sequence of pairs of bytes.
The initial :term:`metadata`.
"""
raise NotImplementedError()

Expand All @@ -323,7 +323,7 @@ def trailing_metadata(self):
This method blocks until the value is available.
Returns:
The trailing metadata as a sequence of pairs of bytes.
The trailing :term:`metadata`.
"""
raise NotImplementedError()

Expand Down Expand Up @@ -394,8 +394,7 @@ def __call__(self, metadata, error):
"""Inform the gRPC runtime of the metadata to construct a CallCredentials.
Args:
metadata: An iterable of 2-sequences (e.g. tuples) of metadata key/value
pairs.
metadata: The :term:`metadata` used to construct the CallCredentials.
error: An Exception to indicate error or None to indicate success.
"""
raise NotImplementedError()
Expand Down Expand Up @@ -442,7 +441,7 @@ def __call__(self, request, timeout=None, metadata=None, credentials=None):
Args:
request: The request value for the RPC.
timeout: An optional duration of time in seconds to allow for the RPC.
metadata: An optional sequence of pairs of bytes to be transmitted to the
metadata: Optional :term:`metadata` to be transmitted to the
service-side of the RPC.
credentials: An optional CallCredentials for the RPC.
Expand All @@ -463,7 +462,7 @@ def with_call(self, request, timeout=None, metadata=None, credentials=None):
Args:
request: The request value for the RPC.
timeout: An optional durating of time in seconds to allow for the RPC.
metadata: An optional sequence of pairs of bytes to be transmitted to the
metadata: Optional :term:`metadata` to be transmitted to the
service-side of the RPC.
credentials: An optional CallCredentials for the RPC.
Expand All @@ -484,7 +483,7 @@ def future(self, request, timeout=None, metadata=None, credentials=None):
Args:
request: The request value for the RPC.
timeout: An optional duration of time in seconds to allow for the RPC.
metadata: An optional sequence of pairs of bytes to be transmitted to the
metadata: Optional :term:`metadata` to be transmitted to the
service-side of the RPC.
credentials: An optional CallCredentials for the RPC.
Expand All @@ -507,7 +506,7 @@ def __call__(self, request, timeout=None, metadata=None, credentials=None):
Args:
request: The request value for the RPC.
timeout: An optional duration of time in seconds to allow for the RPC.
metadata: An optional sequence of pairs of bytes to be transmitted to the
metadata: An optional :term:`metadata` to be transmitted to the
service-side of the RPC.
credentials: An optional CallCredentials for the RPC.
Expand All @@ -530,7 +529,7 @@ def __call__(
Args:
request_iterator: An iterator that yields request values for the RPC.
timeout: An optional duration of time in seconds to allow for the RPC.
metadata: An optional sequence of pairs of bytes to be transmitted to the
metadata: Optional :term:`metadata` to be transmitted to the
service-side of the RPC.
credentials: An optional CallCredentials for the RPC.
Expand All @@ -553,7 +552,7 @@ def with_call(
Args:
request_iterator: An iterator that yields request values for the RPC.
timeout: An optional duration of time in seconds to allow for the RPC.
metadata: An optional sequence of pairs of bytes to be transmitted to the
metadata: Optional :term:`metadata` to be transmitted to the
service-side of the RPC.
credentials: An optional CallCredentials for the RPC.
Expand All @@ -575,7 +574,7 @@ def future(
Args:
request_iterator: An iterator that yields request values for the RPC.
timeout: An optional duration of time in seconds to allow for the RPC.
metadata: An optional sequence of pairs of bytes to be transmitted to the
metadata: Optional :term:`metadata` to be transmitted to the
service-side of the RPC.
credentials: An optional CallCredentials for the RPC.
Expand All @@ -599,7 +598,7 @@ def __call__(
Args:
request_iterator: An iterator that yields request values for the RPC.
timeout: An optional duration of time in seconds to allow for the RPC.
metadata: An optional sequence of pairs of bytes to be transmitted to the
metadata: Optional :term:`metadata` to be transmitted to the
service-side of the RPC.
credentials: An optional CallCredentials for the RPC.
Expand Down Expand Up @@ -707,7 +706,7 @@ def invocation_metadata(self):
"""Accesses the metadata from the invocation-side of the RPC.
Returns:
The invocation metadata object as a sequence of pairs of bytes.
The invocation :term:`metadata`.
"""
raise NotImplementedError()

Expand All @@ -728,8 +727,7 @@ def send_initial_metadata(self, initial_metadata):
service-side initial metadata to transmit.
Args:
initial_metadata: The initial metadata of the RPC as a sequence of pairs
of bytes.
initial_metadata: The initial :term:`metadata`.
"""
raise NotImplementedError()

Expand All @@ -741,8 +739,7 @@ def set_trailing_metadata(self, trailing_metadata):
service-side trailing metadata to transmit.
Args:
trailing_metadata: The trailing metadata of the RPC as a sequence of pairs
of bytes.
trailing_metadata: The trailing :term:`metadata`.
"""
raise NotImplementedError()

Expand Down Expand Up @@ -815,7 +812,7 @@ class HandlerCallDetails(six.with_metaclass(abc.ABCMeta)):
"""Describes an RPC that has just arrived for service.
Attributes:
method: The method name of the RPC.
invocation_metadata: The metadata from the invocation side of the RPC.
invocation_metadata: The :term:`metadata` from the invocation side of the RPC.
"""


Expand Down

0 comments on commit f7f47a6

Please sign in to comment.