Source code for bibstuff.bibstyles.default
"""
:mod:`bibstuff.bibstyles.default`: default citation and reference style
-----------------------------------------------------------------------
Produces a list of citations that to be included in a reStructuredText document.
(In very simple documents, can also provide citation reference formatting
by substituting in the document text for the citation references.)
A style includes:
- citation template
- CitationManager class
- sortkey for make_text_output
(often based on a field list)
:note: you will often want to override these
:note: shared.py holds defintions common to most styles
:note: see the examples (e.g., example_numbered.py) of different styles
:copyright: 2006 Alan G Isaac, see AUTHORS
:license: MIT (see LICENSE)
"""
__docformat__ = "restructuredtext en"
__author__ = "Alan G. Isaac"
__version__ = "0.6"
__needs__ = '2.4'
################### IMPORTS ##########################
# from standard library
import logging
style_logger = logging.getLogger('bibstuff_logger')
#shared_logger = logging.getLogger('bibstuff_logger')
# imports from bibstuff
# :IMPORTANT: every style must import shared!
from . import shared
# most styles with start with the default templates:
# in default_templates.py
from . import default_templates
########################################################
##########################################################################
################### CITEREF FORMATTING #################################
##########################################################################
CITEREF_TEMPLATE = default_templates.DEFAULT_CITEREF_TEMPLATE.copy()
##########################################################################
################## CITATION FORMATTING #################################
##########################################################################
"""
Every style must have a CITATION_TEMPLATE, a CitationManager, and a ref_list_sort_key.
Crucial formatting decisions are made int the CITATION_TEMPLATE.
The CITATION_TEMPLATE provides default reference formatting (may also be used by BibStyle)
:TODO:
- provide graceful handling of missing fields
- allow different formatting of first and other names
- allow different initial line and subsequent line indenting
"""
# here we simply use the default citation template
CITATION_TEMPLATE = shared.CitationManager.default_citation_template
[docs]class CitationManager(shared.CitationManager):
################### CITEREF FORMATTING #########################
#we set the 'format_inline_cite' method equal to the below 'format_inline_cite' function
[docs] def get_citation_label(self,entry,citation_template=None):
return '.. [' + entry.citekey + ']\n'
#sort_key for sorting list of references
# (choice of field_list is a formatting decision)
[docs] def sortkey(self,bibentry):
return self.make_sort_key(bibentry,['Author','Year'])