Skip to main content

No project description provided

Project description

Bibliograpy

Bibliography management to decorate source code.

example workflow

Anaconda-Server Badge Anaconda-Server Badge Anaconda-Server Badge Anaconda-Server Badge Anaconda-Server Badge

PyPI repository Badge

Bibliograpy allows to manage bibliographic centralized references.

  1. Re-use bibliographic standards. As an executable tool, it generates python bibliography modules mapping bibliographic files to python constant representations.

  2. Make bibliographic references easy to use and to maintain. As an API, it allows to decorate functions, classes and methods in the source code, referencing the centralized python constant bibliographies, defined only once and for all.

  3. Transparently inject bibliographic references in docstrings. As an underlying documentation library, it supplements the docstring of decorated elements with bibliographical information.

Preprocessing tool

The bibliograpy process tool allows generating a source code bibliograpy from a resource bibliography file.

Supported formats and syntaxes

bibliograpy process supports bibliography files in Bibtex, RIS (2001) or RIS (2011) formats.

Each format can be expressed in its own syntax or using an equivalent representation in YAML or JSON.

Supported syntaxes for Bibtex bibliographies

For instance, let us consider a Bibtex bibliography expressed in the Bibtex proper syntax:

@misc{nasa
  title = {NASA}
}

@misc{iau,
  title = {International Astronomical Union}
 }

But it can also be expressed in YAML:

- entry_type: misc
  cite_key: nasa
  title: NASA
- entry_type: misc
  cite_key: iau
  title: International Astronomical Union

Or in JSON:

[
  {
    "entry_type": "misc",
    "cite_key": "nasa",
    "title": "NASA"
  },
  {
    "entry_type": "misc",
    "cite_key": "iau",
    "title": "International Astronomical Union"
  }
]

Note the entry_type and cite_key fields used in YAML/JSON to map the Bibtex entry type and cite key values.

Supported syntaxes for RIS (2001) / RIS (2011) bibliographies

Let us consider now an equivalent of the previous bibliography, now given in RIS (2001) format:

TY  - GEN
ID  - nasa
T1  - NASA
ER  -
TY  - GEN
ID  - iau
T1  - International Astronomical Union
ER  -

As for Bibtex, the bibliograpy process tool supports a RIS (2001) bibliography to be expressed using equivalent YAML or JSON syntaxes, respectively:

- TY: GEN
  ID: nasa
  T1: NASA
- TY: GEN
  ID: iau
  T1: International Astronomical Union
[
  {
    "TY": "GEN",
    "ID": "nasa",
    "T1": "NASA"
  },
  {
    "TY": "GEN",
    "ID": "iau",
    "T1": "International Astronomical Union"
  }
]

Processing bibliographies

Bibliography file can be preprocessed by the bibliograpy process tool to produces bibliography python modules.

For instance, there is the python processing result of the previous Bibtex bibliography sample:

from bibliograpy.api_bibtex import Misc

NASA = Misc.generic(cite_key='nasa',
                    title='NASA')

IAU = Misc.generic(cite_key='iau',
                   title='International Astronomical Union')

And there is the processing result of the RIS (2001) one:

from bibliograpy.api_ris2001 import *

NASA = {
    Tags.TY: TypeFieldName.GEN,
    Tags.ID: 'nasa',
    Tags.T1: 'NASA'
}

IAU = {
    Tags.TY: TypeFieldName.GEN,
    Tags.ID: 'iau',
    Tags.T1: 'International Astronomical Union'
}

By default, the bibliograpy process tool searches for a bibliograpy.yaml file reproducing the Bibtex format.

bibliograpy process

Is equivalent to:

bibliograpy process --format=bibtex bibliograpy.yaml

Note the format is parameterized through the --format option as the syntax is inferred from the bibliography file extension.

Moreover, for a given format, the bibliograpy process tool allow to convert a bibliography file from one of the JSON, YAML and standard syntaxes to another one. It does not convert a format to another one.

Cross-referencing support (Bibtex format)

The bibliograpy process tool support the cross-referencing/inheritance mechanism specified by the Bibtex format.

Example, from a bibtex bibliography (bibliograpy.bib):

@misc{ogc,
 institution = {OGC},
 title = {Open Geospatial Consortium}
}

@misc{zeitschrift_fur_vermessungswesen,
 journal = {Zeitschrift für Vermessungswesen},
 title = {Zeitschrift für Vermessungswesen}
}

@techreport{cts_revision_v1_0,
 author = {},
 crossref = {ogc},
 month = {January},
 number = {OGC 01-009},
 title = {Coordinate Transformation Services},
 type = {standard},
 year = {2001}
}

@article{joachim_boljen_2004,
 author = {},
 crossref = {zeitschrift_fur_vermessungswesen},
 pages = {258-260},
 title = {Zur geometrischen Interpretation und direkten Bestimmung von Formfunktionen},
 volume = {129},
 year = {2004}
}
bibliograpy process bibliograpy.bib

When processed, the bibliography produces python constants to import in the code which uses the very bibliographical references as cross-references from other ones.

from bibliograpy.api_bibtex import *


OGC = Misc.generic(cite_key='ogc',
                   institution='OGC',
                   title='Open Geospatial Consortium')

ZEITSCHRIFT_FUR_VERMESSUNGSWESEN = Misc.generic(cite_key='zeitschrift_fur_vermessungswesen',
                                                journal='Zeitschrift für Vermessungswesen',
                                                title='Zeitschrift für Vermessungswesen',
                                                non_standard=NonStandard(issn='0044-3689'))

CTS_REVISION_V1_0 = TechReport.generic(cite_key='cts_revision_v1_0',
                                       author='',
                                       crossref=OGC,
                                       month='January',
                                       number='OGC 01-009',
                                       title='Coordinate Transformation Services',
                                       type='standard',
                                       year=2001,
                                       non_standard=NonStandard(url='https://portal.ogc.org/files/?artifact_id=999'))

JOACHIM_BOLJEN_2004 = Article.generic(cite_key='joachim_boljen_2004',
                                      author='',
                                      crossref=ZEITSCHRIFT_FUR_VERMESSUNGSWESEN,
                                      pages='258-260',
                                      title='Zur geometrischen Interpretation und direkten Bestimmung von Formfunktionen',
                                      volume='129',
                                      year=2004,
                                      non_standard=NonStandard(url='https://geodaesie.info/system/files/privat/zfv_2004_4_Boljen.pdf'))

Nevertheless, to be actually cross-resolved by the underlying Bibliograpy library, all the references must use a scope which have to be named and initialized through respectively --scope and --init-scope options.

bibliograpy process --scope=_SCOPE --init-scope="_SCOPE = {}" bibliograpy.bib
from bibliograpy.api_bibtex import *

_SCOPE = {}


OGC = Misc.generic(cite_key='ogc',
                   institution='OGC',
                   title='Open Geospatial Consortium',
                   scope=_SCOPE)

ZEITSCHRIFT_FUR_VERMESSUNGSWESEN = Misc.generic(cite_key='zeitschrift_fur_vermessungswesen',
                                                journal='Zeitschrift für Vermessungswesen',
                                                title='Zeitschrift für Vermessungswesen',
                                                non_standard=NonStandard(issn='0044-3689'),
                                                scope=_SCOPE)

CTS_REVISION_V1_0 = TechReport.generic(cite_key='cts_revision_v1_0',
                                       author='',
                                       crossref=OGC,
                                       month='January',
                                       number='OGC 01-009',
                                       title='Coordinate Transformation Services',
                                       type='standard',
                                       year=2001,
                                       non_standard=NonStandard(url='https://portal.ogc.org/files/?artifact_id=999'),
                                       scope=_SCOPE)

JOACHIM_BOLJEN_2004 = Article.generic(cite_key='joachim_boljen_2004',
                                      author='',
                                      crossref=ZEITSCHRIFT_FUR_VERMESSUNGSWESEN,
                                      pages='258-260',
                                      title='Zur geometrischen Interpretation und direkten Bestimmung von Formfunktionen',
                                      volume='129',
                                      year=2004,
                                      non_standard=NonStandard(url='https://geodaesie.info/system/files/privat/zfv_2004_4_Boljen.pdf'),
                                      scope=_SCOPE)

A default SHARED_SCOPE shared scope is provided by the bibliograpy.api_bibtex module. If this name is supplied to the --scope option, no initialization is necessary (unless the user wants to shadow the common SHARED_SCOPE).

API / Documentation library

Hence, is it possible to factorize all bibliographic sources contained in a bibliography file as variables in a python module.

Then, the Bibliograpy API allows using them as arguments of decorators.

"""The bibliography module."""

from bibliograpy.api_bibtex import TechReport

IAU_2006_B1 = TechReport.generic(
    cite_key='iau_2006_b1',
    author='',
    institution='iau',
    title='Adoption of the P03 Precession Theory and Definition of the Ecliptic',
    year=2006)
"""The bibliography_client module using the bibliography module."""

from bibliograpy.api_common import cite

from bibliography import IAU_2006_B1

@cite(IAU_2006_B1)
def my_function():
    """My my_function documentation."""
    return "Hello IAU !"

The usage of the decorator has two purposes.

First, to use a bibliographic reference defined once and for all, centralized and reusable, easy to maintain, update, refactor and search for usage.

Second, to implicitly add to the documentation of the decorated entities a bibliographical section.

import bibliography_client

>>> help(my_function)
Help on function my_function in module bibliography_client

my_function()
    My my_function documentation.

    Bibliography: Adoption of the P03 Precession Theory and Definition of the Ecliptic [iau_2006_b1]

Documentation

Latest release

Trunk

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bibliograpy-0.4.0.tar.gz (35.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bibliograpy-0.4.0-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

Details for the file bibliograpy-0.4.0.tar.gz.

File metadata

  • Download URL: bibliograpy-0.4.0.tar.gz
  • Upload date:
  • Size: 35.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.2

File hashes

Hashes for bibliograpy-0.4.0.tar.gz
Algorithm Hash digest
SHA256 176234a87b2e9b884dfb2526a8130609c5b353263a13777d8fcaec7ec80264e3
MD5 cbb97a4413dfcdd84abf7b782251c070
BLAKE2b-256 5d472fcb5fcaa37f9a225c142c7289f862483720a12a6c6296e4b41253ff9f8e

See more details on using hashes here.

File details

Details for the file bibliograpy-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: bibliograpy-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 27.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.2

File hashes

Hashes for bibliograpy-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 88c4767f5a905ee485821a2a5f394823761481a95e70b91de36d62c6e0852de9
MD5 3f665410c45f31df62291f2a32314dd1
BLAKE2b-256 cfda671192570dad3aedfe8933c8a9e461ef652e1c216adc636875d8f5cabd34

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page