Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Sphinx config #415

Merged
merged 15 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ Dockerfile-*linux*[^.template]

# Units (pint) files
units.cpython-*.pyc
bindings/python/triplestore/__pycache__
bindings/python/triplestore/__pycache__

# Documentation
pydoc/autoapi/
11 changes: 6 additions & 5 deletions bindings/python/dlite-entity-python.i
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Python -*- (not really, but good for syntax highlighting) */

/* Python-spesific extensions to dlite-entity.i */
/* Python-specific extensions to dlite-entity.i */
%pythoncode %{
import sys
import json
Expand Down Expand Up @@ -115,18 +115,19 @@ def standardise(v, prop, asdict=False):
return conv(v)


def get_instance(id: "str", metaid: "str"=None, check_storages: "bool"=True) -> "Instance":
def get_instance(id: "str", metaid: "str" = None, check_storages: "bool" = True) -> "Instance":
"""Return instance with given id.

Arguments:
id: Id of instance to return.
id: ID of instance to return.
metaid: If given, dlite will try to convert the instance to a new
instance of `metaid`.
instance of ``metaid``.
check_storages: Whether to check for the instance in storages listed
in dlite.storage_path if the instance is not already in memory.

Returns:
DLite instance.
DLite Instance.

"""
if isinstance(id, dlite.Instance):
inst = id
Expand Down
46 changes: 30 additions & 16 deletions bindings/python/dlite-entity.i
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,23 @@ struct _DLiteDimension {
%feature("docstring", "\
Creates a new property.

```python
Property(name, type, dims=None, unit=None, description=None)
Creates a new property with the provided attributes.
```

Creates a new property with the provided attributes.

```python
Property(seq)
Creates a new property from sequence of 6 strings, corresponding to
`name`, `type`, `dims`, `unit` and `description`. Valid
values for `dims` are:
- '' or '[]': no dimensions
- '<dim1>, <dim2>': list of dimension names
- '[<dim1>, <dim2>]': list of dimension names
```

Creates a new property from sequence of 6 strings, corresponding to
``name``, ``type``, ``dims``, ``unit`` and ``description``.
Valid values for ``dims`` are:

- ``''`` or ``'[]'``: No dimensions.
- ``'<dim1>, <dim2>'``: List of dimension names.
- ``'[<dim1>, <dim2>]'``: List of dimension names.

") _DLiteProperty;
%rename(Property) _DLiteProperty;
Expand Down Expand Up @@ -608,15 +615,22 @@ Call signatures:
dlite_swig_set_property_by_index($self, i, obj);
}

%feature("docstring",
"Return property `name` as a string.\n"
"\n"
"`width` Minimum field width. Unused if 0, auto if -1.\n"
"`prec` Precision. Auto if -1, unused if -2.\n"
"`flags` Or'ed sum of formatting flags:\n"
" 0 default (json)\n"
" 1 raw unquoted output\n"
" 2 quoted output")
%feature("docstring", "\
Return property ``name`` as a string.

Parameters:
width: Minimum field width. Unused if 0, auto if -1.
prec: Precision. Auto if -1, unused if -2.
flags: Or'ed sum of formatting flags:

- ``0``: Default (json).
- ``1``: Raw unquoted output.
- ``2``: Quoted output.

Returns:
Property as a string.

")
get_property_as_string;
%newobject get_property_as_string;
char *get_property_as_string(const char *name,
Expand Down
14 changes: 8 additions & 6 deletions bindings/python/dlite-misc-python.i
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import dlite
class err():
"""Context manager for temporary turning off or redirecting errors.

By default errors are skipped within the err context. But if
`filename` is provided, the error messages are written to that file.
Special file names includes
- None or empty: no output is written
- <stderr>: write errors to stderr (default)
- <stdout>: write errors to stdout
By default errors are skipped within the err context. But if
``filename`` is provided, the error messages are written to that file.
Special file names includes:

- ``None`` or empty: No output is written.
- ``<stderr>``: Write errors to stderr (default).
- ``<stdout>``: Write errors to stdout.

"""
def __init__(self, filename=None):
self.filename = filename
Expand Down
43 changes: 24 additions & 19 deletions bindings/python/dlite-misc.i
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,24 @@ const char *dlite_get_license(void);

%feature("docstring", "\
Returns an UUID, depending on:
- If `id` is NULL or empty, generates a new random version 4 UUID.
- If `id` is not a valid UUID string, generates a new version 5 sha1-based
UUID from `id` using the DNS namespace.
- Otherwise return `id` (which already must be a valid UUID).

- If ``id`` is NULL or empty, generates a new random version 4 UUID.
- If ``id`` is not a valid UUID string, generates a new version 5 sha1-based
UUID from ``id`` using the DNS namespace.

Otherwise return ``id`` (which already must be a valid UUID).
") dlite_get_uuid;
%cstring_bounded_output(char *buff36, DLITE_UUID_LENGTH+1);
void dlite_get_uuid(char *buff36, const char *id=NULL);

%feature("docstring", "\
Returns the generated UUID version number if `id` had been passed to
get_uuid() or zero if `id` is already a valid UUID.
Returns the generated UUID version number if ``id`` had been passed to
get_uuid() or zero if ``id`` is already a valid UUID.
") get_uuid_version;
posstatus_t get_uuid_version(const char *id=NULL);

%feature("docstring", "\
Returns a (metadata) uri by combining `name`, `version` and `namespace` as:
Returns a (metadata) uri by combining ``name``, ``version`` and ``namespace`` as:

namespace/version/name
") dlite_join_meta_uri;
Expand All @@ -66,7 +68,7 @@ char *dlite_join_meta_uri(const char *name, const char *version,


%feature("docstring", "\
Returns (name, version, namespace)-tuplet from valid metadata `uri`.
Returns (name, version, namespace)-tuplet from valid metadata ``uri``.
") dlite_split_meta_uri;
%cstring_output_allocate(char **name, if (*$1) free(*$1));
%cstring_output_allocate(char **version, if (*$1) free(*$1));
Expand All @@ -81,15 +83,15 @@ Returns an url constructed from the arguments of the form:

driver://location?options#fragment

The `driver`, `options` and `fragment` arguments may be None.
The ``driver``, ``options`` and ``fragment`` arguments may be None.
") dlite_join_url;
%newobject dlite_join_url;
char *dlite_join_url(const char *driver, const char *location,
const char *options=NULL, const char *fragment=NULL);

%feature("docstring", "\
Returns a (driver, location, options, fragment)-tuplet by splitting
`url` of the form
``url`` of the form

driver://location?options#fragment

Expand All @@ -108,11 +110,12 @@ Match string 's' against glob pattern 'pattern' and return zero on
match.

Understands the following patterns:
* any number of characters
? any single character
[a-z] any single character in the range a-z
[^a-z] any single character not in the range a-z
\x match x

- ``*``: Any number of characters.
- ``?``: Any single character.
- ``[a-z]``: Any single character in the range a-z.
- ``[^a-z]``: Any single character not in the range a-z.
- ``\\x``: Match x.
") globmatch;
int globmatch(const char *pattern, const char *s);

Expand Down Expand Up @@ -145,10 +148,12 @@ Set error stream.
void dlite_err_set_stream(FILE *);

%feature("docstring", "\
Set error log file. Special values includes:
- None | "": turn off error output
- <stderr>: standard error
- <stdout>: standard output
Set error log file. Special values includes:

- ``None`` or empty: Turn off error output.
- ``<stderr>``: Standard error.
- ``<stdout>``: Standard output.

All other values are treated as a filename that will be opened in append mode.
") dlite_err_set_file;
void dlite_err_set_file(const char *filename);
Expand Down
24 changes: 13 additions & 11 deletions bindings/python/dlite-storage.i
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

/* Storage iterator */
%feature("docstring", "\
Iterates over instances in storage `s`. If `pattern` is given, only
instances whos metadata URI matches `pattern` are returned.
Iterates over instances in storage ``s``. If ``pattern`` is given, only
instances whos metadata URI matches ``pattern`` are returned.
") StorageIterator;
%inline %{
struct StorageIterator {
Expand Down Expand Up @@ -57,7 +57,7 @@ Returns next instance or None if exhausted.") next;
enum _DLiteIDFlag {
dliteIDTranslateToUUID=0, /*!< Translate id's that are not a valid UUID to
a (version 5) UUID (default). */
dliteIDRequireUUID=1, /*!< Require that `id` is a valid UUID. */
dliteIDRequireUUID=1, /*!< Require that ``id`` is a valid UUID. */
dliteIDKeepID=2 /*!< Store data under the given id, even if it
is not a valid UUID. Not SOFT compatible,
but may be useful for input files. */
Expand All @@ -71,21 +71,23 @@ Represents a data storage.
Parameters
----------
driver_or_url : string
Name of driver used to connect to the storage or, if `location` is not
Name of driver used to connect to the storage or, if ``location`` is not
given, the URL to the storage:

driver://location?options

location : string
The location to the storage. For file storages, this is the file name.
The location to the storage. For file storages, this is the file name.
options : string
Additional options passed to the driver as a list of semicolon-separated
``key=value`` pairs. Each driver may have their own options. Some
``key=value`` pairs. Each driver may have their own options. Some
common options are:
- mode={'append','r','w'}: 'append': append to existing storage or
create a new one (hdf5,json).
- compact={'yes','no'}: Whether to store in a compact format (json).
- meta={'yes','no'}: Whether to format output as metadata (json).

- ``mode={'append','r','w'}``:
- 'append': Append to existing storage or create a new one (hdf5,json).
- ``compact={'yes','no'}``: Whether to store in a compact format (json).
- ``meta={'yes','no'}``: Whether to format output as metadata (json).

") _DLiteStorage;
%rename(Storage) _DLiteStorage;

Expand Down Expand Up @@ -120,7 +122,7 @@ Returns name of driver for this storage.") get_driver;

%feature("docstring", "\
Returns a list of UUIDs of all instances in the storage whos metadata
matches `pattern`. If `pattern` is None, all UUIDs will be returned.
matches ``pattern``. If ``pattern`` is None, all UUIDs will be returned.
") get_uuids;
char **get_uuids(const char *pattern=NULL) {
return dlite_storage_uuids($self, pattern);
Expand Down
Loading