sphobjinv.data¶
sphobjinv
data classes for individual objects.
sphobjinv
is a toolkit for manipulation and inspection of
Sphinx objects.inv files.
- Author
- Brian Skinn (bskinn@alum.mit.edu)
- File Created
- 7 Nov 2017
- Copyright
- (c) Brian Skinn 2016-2018
- Source Repository
- http://www.github.com/bskinn/sphobjinv
- Documentation
- http://sphobjinv.readthedocs.io
- License
- The MIT License; see LICENSE.txt for full license terms
Members
-
class
DataFields
¶ Enum
for the fields of objects.inv data objects.-
DispName
= 'dispname'¶ Default display name for the object in rendered documentation when referenced as :domain:role:`name`
-
Domain
= 'domain'¶ Sphinx domain housing the object
-
Name
= 'name'¶ Object name, as recognized internally by Sphinx
-
Priority
= 'priority'¶ Object search priority
-
Role
= 'role'¶ Full name of Sphinx role to be used when referencing the object
-
URI
= 'uri'¶ URI to the location of the object’s documentation, relative to the documentation root
-
-
class
DataObjBytes
(name, domain, role, priority, uri, dispname, as_str=NOTHING, as_bytes=NOTHING)¶ SuperDataObj
subclass generatingbytes
object data.-
as_bytes
¶ DataObjBytes
version of instance.
-
as_str
¶ DataObjStr
version of instance.
-
dispname
¶ Object default name in rendered documentation\(^\dagger\).
Possibly abbreviated; see here.
-
domain
¶ Sphinx domain containing the object\(^\dagger\).
-
name
¶ Object name, as recognized internally by Sphinx\(^\dagger\).
-
priority
¶ Object search priority\(^\dagger\).
-
role
¶ Sphinx role to be used when referencing the object\(^\dagger\).
-
-
class
DataObjStr
(name, domain, role, priority, uri, dispname, as_bytes=NOTHING, as_str=NOTHING)¶ SuperDataObj
subclass generatingstr
object data.-
as_bytes
¶ DataObjBytes
version of instance.
-
as_str
¶ DataObjStr
version of instance.
-
dispname
¶ Object default name in rendered documentation\(^\dagger\).
Possibly abbreviated; see here.
-
domain
¶ Sphinx domain containing the object\(^\dagger\).
-
name
¶ Object name, as recognized internally by Sphinx\(^\dagger\).
-
priority
¶ Object search priority\(^\dagger\).
-
role
¶ Sphinx role to be used when referencing the object\(^\dagger\).
-
-
class
SuperDataObj
¶ Abstract base superclass defining common methods &c. for data objects.
Intended only to be subclassed by
DataObjBytes
andDataObjStr
, to allow definition of common methods, properties, etc. all in one place.Where marked with \(^\dagger\),
DataObjBytes
instances will returnbytes
values, whereasDataObjStr
instances will returnstr
values.-
as_bytes
¶ DataObjBytes
version of instance.
-
as_rst
¶ str
reST reference-like object representation.Typically will NOT function as a proper reST reference in Sphinx source (e.g., a role of function must be referenced using :func: for the py domain).
-
as_str
¶ DataObjStr
version of instance.
-
data_line
(*, expand=False, contract=False)¶ Compose plaintext objects.inv data line from instance contents.
The format of the resulting data line is given by
data_line_fmt
.DataObjBytes
andDataObjStr
instances generate data lines asbytes
andstr
, respectively.Calling with both expand and contract as
True
is invalid.Parameters: Returns: dl –
bytes
(forDataObjBytes
) orstr
(forDataObjStr
) – Object data lineRaises: ValueError
– If both expand and contract areTrue
-
data_line_fmt
= '{name} {domain}:{role} {priority} {uri} {dispname}'¶ Helper
str
for generating plaintext objects.inv data lines. The field names MUST match thestr
values of theDataFields
members.
-
dispname
¶ Object default name in rendered documentation\(^\dagger\).
Possibly abbreviated; see here.
-
dispname_abbrev
¶ Abbreviation character(s) for display name\(^\dagger\).
'-'
orb'-'
for version 2 objects.inv files.
-
dispname_contracted
¶ Object display name, contracted with dispname_abbrev.
-
dispname_expanded
¶ Object display name, with dispname_abbrev expanded.
-
domain
¶ Sphinx domain containing the object\(^\dagger\).
-
evolve
(**kwargs)¶ Create a new instance with changes applied.
This helper method provides a concise means for creating new instances with only a subset of changed data fields.
The names of any kwargs MUST be keys of the
dict
s generated byjson_dict()
.Parameters: **kwargs – str
orbytes
– Revised value(s) to use in the new instance for the passed keyword argument(s).Returns: dobj – DataObjBytes
orDataObjStr
– New instance with updated data
-
json_dict
(*, expand=False, contract=False)¶ Return the object data formatted as a flat
dict
.The returned
dict
is constructed such that it matches the relevant subschema ofsphobjinv.schema.json_schema
, to facilitate implementation ofInventory.json_dict()
.The
dict
s returned byDataObjBytes
andDataObjStr
both havestr
keys, but they havebytes
andstr
values, respectively. Thedict
keys are identical to thestr
values of theDataFields
Enum
members.Calling with both expand and contract as
True
is invalid.Parameters: Returns: d –
dict
– Object dataRaises: ValueError
– If both expand and contract areTrue
-
name
¶ Object name, as recognized internally by Sphinx\(^\dagger\).
-
priority
¶ Object search priority\(^\dagger\).
-
role
¶ Sphinx role to be used when referencing the object\(^\dagger\).
-
rst_fmt
= ':{domain}:{role}:`{name}`'¶ str.format()
template for generating reST-like representations of object data foras_rst
(used withInventory.suggest()
).
-
uri_abbrev
¶ Abbreviation character(s) for URI tail\(^\dagger\).
'$'
orb'$'
for version 2 objects.inv files.
-
uri_contracted
¶ Object relative URI, contracted with uri_abbrev.
-
uri_expanded
¶ Object relative URI, with uri_abbrev expanded.
-