Currently, defining a custom writer is possible but not straightforward.
- It is not clear that you have to initialize a writer and then change the attributes that were initialized. Having the attributes exposed as arguments of
__init__(), with detailed docstrings used by the sphinx-build, might improve the experience. Example using numpy style docstrings:
class BibTexWriter(object):
"""
Writer to convert a :class:`BibDatabase` object to a string or file formatted as a BibTeX file.
Parameters
-----------
param1 : type
description
param2 : type
description
...
"""
def __init__(self, param1, param2, ...):
pass
-
Sorting of the fields is hidden in the undocumented SortingStrategy class.
-
Most people will not define a custom writer and are simply going to use the dump function. The most common configuration should be accessible directly at the dump function level, e.g. sorting of entries and sorting of fields. Example:
def dump(
bib_database: BibDatabase,
bibtex_file: TextIO,
writer: Optional[BibTexWriter] = None,
order_entries: Optional[Tuple[str]] = None,
order_fields: Optional[str] = None,
):
pass
In the example above, None corresponds to "preserve" order. order_entries corresponds to the writer's attribute order_entries_by and order_fields corresponds to the writer's attribute display_order_sorting.
Originally posted in #336
x-ref with v2: #318
Currently, defining a custom writer is possible but not straightforward.
__init__(), with detailed docstrings used by the sphinx-build, might improve the experience. Example usingnumpystyle docstrings:Sorting of the fields is hidden in the undocumented
SortingStrategyclass.Most people will not define a custom writer and are simply going to use the
dumpfunction. The most common configuration should be accessible directly at thedumpfunction level, e.g. sorting of entries and sorting of fields. Example:In the example above,
Nonecorresponds to"preserve"order.order_entriescorresponds to the writer's attributeorder_entries_byandorder_fieldscorresponds to the writer's attributedisplay_order_sorting.Originally posted in #336
x-ref with v2: #318