Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-pipeline
msc
sextractor
Commits
1a9b70b3
Commit
1a9b70b3
authored
Mar 07, 2023
by
Emmanuel Bertin
Browse files
Update doc.
parent
910ccfce
Changes
2
Hide whitespace changes
Inline
Side-by-side
doc/src/adsarxiv.py
0 → 100644
View file @
1a9b70b3
"""
ADSArxiv PybTeX style
"""
# Copyright Emmanuel Bertin CFHT/CNRS/SorbonneU
# Licensed under GPL v3
from
packaging
import
version
as
vers
from
pybtex
import
__version__
as
pybtex_version
from
pybtex.style.formatting.unsrt
import
Style
as
UnsrtStyle
,
date
,
pages
,
toplevel
from
pybtex.style.template
import
*
# ... and anything else needed
from
pybtex.plugin
import
register_plugin
pybtex_new_version
=
vers
.
parse
(
pybtex_version
)
>=
vers
.
parse
(
"0.22"
)
if
pybtex_new_version
:
def
_format_data
(
node
,
data
):
try
:
f
=
node
.
format_data
except
AttributeError
:
return
node
else
:
return
f
(
data
)
def
_format_list
(
list_
,
data
):
return
(
_format_data
(
part
,
data
)
for
part
in
list_
)
@
node
def
href2
(
children
,
data
):
parts
=
_format_list
(
children
,
data
)
if
"http"
in
list
(
parts
)[
0
]:
parts
=
_format_list
(
children
,
data
)
return
richtext
.
HRef
(
*
parts
)
else
:
parts
=
_format_list
(
children
,
data
)
return
richtext
.
Tag
(
'strong'
,
*
parts
)
class
ADSArxivStyle
(
UnsrtStyle
):
if
pybtex_new_version
:
def
format_names
(
self
,
role
,
as_sentence
=
True
):
formatted_names
=
names
(
role
,
sep
=
', '
,
sep2
=
' and '
,
last_sep
=
', and '
)
if
as_sentence
:
return
sentence
[
formatted_names
]
else
:
return
formatted_names
def
get_article_template
(
self
,
e
):
volume_and_pages
=
first_of
[
# volume and pages, with optional issue number
optional
[
join
[
field
(
'volume'
),
optional
[
'('
,
field
(
'number'
),
')'
],
':'
,
pages
],
],
# pages only
words
[
'pages'
,
pages
],
]
myurl
=
first_of
[
optional_field
(
'adsurl'
),
optional
[
join
[
'http://arxiv.org/abs/'
,
field
(
'eprint'
)
]],
optional_field
(
'url'
),
optional
[
join
[
'http://dx.doi.org/'
,
field
(
'doi'
)
]]
]
template
=
toplevel
[
sentence
[
self
.
format_names
(
'author'
,
as_sentence
=
False
),
field
(
'year'
)
],
href2
[
myurl
,
self
.
format_title
(
e
,
'title'
)
],
sentence
(
capfirst
=
False
)
[
tag
(
'emph'
)[
field
(
'journal'
)
],
optional
[
volume_and_pages
]],
sentence
(
capfirst
=
False
)
[
optional_field
(
'note'
)
],
]
return
template
def
get_book_template
(
self
,
e
):
myurl
=
first_of
[
optional_field
(
'adsurl'
),
optional
[
join
[
'http://arxiv.org/abs/'
,
field
(
'eprint'
)
]],
optional_field
(
'url'
),
optional
[
join
[
'http://dx.doi.org/'
,
field
(
'doi'
)
]]
]
template
=
toplevel
[
self
.
format_author_or_editor
(
e
),
href2
[
myurl
,
self
.
format_btitle
(
e
,
'title'
)
],
self
.
format_volume_and_series
(
e
),
sentence
[
field
(
'publisher'
),
optional_field
(
'address'
),
self
.
format_edition
(
e
),
date
],
optional
[
sentence
[
self
.
format_isbn
(
e
)
]
],
sentence
[
optional_field
(
'note'
)
],
]
return
template
def
get_inproceedings_template
(
self
,
e
):
myurl
=
first_of
[
optional_field
(
'adsurl'
),
optional
[
join
[
'http://arxiv.org/abs/'
,
field
(
'eprint'
)
]],
optional_field
(
'url'
),
optional
[
join
[
'http://dx.doi.org/'
,
field
(
'doi'
)
]]
]
template
=
toplevel
[
sentence
[
self
.
format_names
(
'author'
,
as_sentence
=
False
),
field
(
'year'
)
],
href2
[
myurl
,
self
.
format_title
(
e
,
'title'
)
],
words
[
'In'
,
sentence
(
capfirst
=
False
)[
optional
[
self
.
format_editor
(
e
,
as_sentence
=
False
)
],
self
.
format_btitle
(
e
,
'booktitle'
,
as_sentence
=
False
),
self
.
format_volume_and_series
(
e
,
as_sentence
=
False
),
optional
[
pages
],
],
self
.
format_address_organization_publisher_date
(
e
),
],
sentence
(
capfirst
=
False
)[
optional_field
(
'note'
)
],
]
return
template
def
get_misc_template
(
self
,
e
):
myurl
=
first_of
[
optional_field
(
'adsurl'
),
optional
[
join
[
'http://arxiv.org/abs/'
,
field
(
'eprint'
)
]],
optional_field
(
'url'
),
optional
[
join
[
'http://dx.doi.org/'
,
field
(
'doi'
)
]]
]
template
=
toplevel
[
optional
[
sentence
[
self
.
format_names
(
'author'
,
as_sentence
=
False
),
optional
[
field
(
'year'
)
]]],
optional
[
href2
[
myurl
,
self
.
format_title
(
e
,
'title'
)
]],
sentence
[
optional
[
field
(
'howpublished'
)
]],
sentence
[
optional_field
(
'note'
)
],
]
return
template
else
:
def
format_article
(
self
,
e
):
volume_and_pages
=
first_of
[
# volume and pages, with optional issue number
optional
[
join
[
field
(
'volume'
),
optional
[
'('
,
field
(
'number'
),
')'
],
':'
,
pages
],
],
# pages only
words
[
'pages'
,
pages
],
]
myurl
=
first_of
[
optional_field
(
'adsurl'
),
optional
[
join
[
'http://arxiv.org/abs/'
],
field
(
'eprint'
)],
optional_field
(
'url'
),
optional
[
join
[
'http://dx.doi.org/'
,
field
(
'doi'
)]]
]
template
=
toplevel
[
self
.
format_names
(
'author'
),
href
[
myurl
,
self
.
format_title
(
e
,
'title'
)],
sentence
(
capfirst
=
False
)
[
tag
(
'emph'
)
[
field
(
'journal'
)],
optional
[
volume_and_pages
],
field
(
'year'
)],
sentence
(
capfirst
=
False
)
[
optional_field
(
'note'
)
],
]
return
template
.
format_data
(
e
)
def
format_book
(
self
,
e
):
myurl
=
first_of
[
optional_field
(
'adsurl'
),
optional
[
join
[
'http://arxiv.org/abs/'
],
field
(
'eprint'
)],
optional_field
(
'url'
),
optional
[
join
[
'http://dx.doi.org/'
,
field
(
'doi'
)]]
]
template
=
toplevel
[
self
.
format_author_or_editor
(
e
),
href
[
myurl
,
self
.
format_btitle
(
e
,
'title'
)]
\
if
len
(
myurl
.
format_data
(
e
))
>
0
\
else
tag
(
'strong'
)
[
self
.
format_btitle
(
e
,
'title'
)],
self
.
format_volume_and_series
(
e
),
sentence
[
field
(
'publisher'
),
optional_field
(
'address'
),
self
.
format_edition
(
e
),
date
],
optional
[
sentence
[
self
.
format_isbn
(
e
)
]
],
optional_field
(
'note'
),
]
return
template
.
format_data
(
e
)
def
format_inproceedings
(
self
,
e
):
myurl
=
first_of
[
optional_field
(
'adsurl'
),
optional
[
join
[
'http://arxiv.org/abs/'
,
field
(
'eprint'
)]],
optional_field
(
'url'
),
optional
[
join
[
'http://dx.doi.org/'
,
field
(
'doi'
)]]
]
template
=
toplevel
[
sentence
[
self
.
format_names
(
'author'
)],
href
[
myurl
,
self
.
format_title
(
e
,
'title'
)]
\
if
len
(
myurl
.
format_data
(
e
))
>
0
\
else
tag
(
'strong'
)
[
self
.
format_title
(
e
,
'title'
)],
words
[
'In'
,
sentence
(
capfirst
=
False
)
[
optional
[
self
.
format_editor
(
e
,
as_sentence
=
False
)
],
self
.
format_btitle
(
e
,
'booktitle'
,
as_sentence
=
False
),
self
.
format_volume_and_series
(
e
,
as_sentence
=
False
),
optional
[
pages
],
],
self
.
format_address_organization_publisher_date
(
e
),
],
sentence
(
capfirst
=
False
)
[
optional_field
(
'note'
)
],
]
return
template
.
format_data
(
e
)
register_plugin
(
'pybtex.style.formatting'
,
'adsarxiv'
,
ADSArxivStyle
)
doc/src/conf.py.in
View file @
1a9b70b3
...
@@ -16,32 +16,27 @@
...
@@ -16,32 +16,27 @@
# add these directories to sys.path here. If the directory is relative to the
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
#
# import os
import os, sys
# import sys
sys.path.insert(0, os.path.abspath('.'))
# sys.path.insert(0, os.path.abspath('.'))
import sphinx_rtd_theme
import sphinx_rtd_theme
import adsarxiv
# -- General configuration ------------------------------------------------
# -- General configuration ---------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
# ones.
extensions = [
extensions = [
# 'sphinx.ext.intersphinx',
# 'sphinx.ext.todo',
'sphinx.ext.mathjax',
'sphinxcontrib.bibtex',
'sphinxcontrib.bibtex',
'sphinx.ext.githubpages'
'sphinx.ext.githubpages',
'sphinx.ext.mathjax',
'sphinx.ext.todo',
]
]
# Add any paths that contain templates here, relative to this directory.
# Add any paths that contain templates here, relative to this directory.
templates_path = ['
_templates
']
templates_path = ['
../theme
']
# The suffix(es) of source filenames.
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# You can specify multiple suffix as a list of string:
...
@@ -59,7 +54,7 @@ master_doc = 'index'
...
@@ -59,7 +54,7 @@ master_doc = 'index'
# General information about the project.
# General information about the project.
project = u'@PACKAGE_NAME@'
project = u'@PACKAGE_NAME@'
filename = '@PACKAGE_TARNAME@'
filename = '@PACKAGE_TARNAME@'
copyright = u'2017
, IAP/CNRS/UPMC
'
copyright = u'2017
-2023, CFHT/IAP/CNRS/SorbonneU
'
author = u'E. Bertin'
author = u'E. Bertin'
# The version info for the project you're documenting, acts as replacement for
# The version info for the project you're documenting, acts as replacement for
...
@@ -71,13 +66,6 @@ version = '@PACKAGE_VERSION@'
...
@@ -71,13 +66,6 @@ version = '@PACKAGE_VERSION@'
# The full version, including alpha/beta/rc tags.
# The full version, including alpha/beta/rc tags.
release = '@PACKAGE_VERSION@'
release = '@PACKAGE_VERSION@'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# There are two options for replacing |today|: either, you set today to some
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
# non-false value, then it is used:
#
#
...
@@ -90,21 +78,7 @@ today = '@DATE2@'
...
@@ -90,21 +78,7 @@ today = '@DATE2@'
# List of patterns, relative to source directory, that match files and
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['global.rst','keys.rst','roles.rst']
exclude_patterns = ['global.rst','keys.rst','macro.rst','roles.rst']
# The reST default role (used for this markup: `text`) to use for all
# documents.
#
# default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#
# add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#
# add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
# output. They are ignored by default.
...
@@ -114,53 +88,17 @@ exclude_patterns = ['global.rst','keys.rst','roles.rst']
...
@@ -114,53 +88,17 @@ exclude_patterns = ['global.rst','keys.rst','roles.rst']
# The name of the Pygments (syntax highlighting) style to use.
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
# keep_warnings = False
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
numfig = True
numfig = True
# -- Options for HTML output ----------------------------------------------
smartquotes = False
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
# a list of builtin themes.
#
#
html_theme = 'sphinx_rtd_theme'
html_theme = 'sphinx_rtd_theme'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
# The name for this set of Sphinx documents.
# "<project> v<release> documentation" by default.
#
# html_title = u'@PACKAGE_NAME@ v@PACKAGE_VERSION@'
# A shorter title for the navigation bar. Default is the same as html_title.
#
# html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#
# html_logo = None
# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#
# html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
# so a file named "default.css" will overwrite the builtin "default.css".
...
@@ -168,49 +106,7 @@ html_static_path = ['../theme']
...
@@ -168,49 +106,7 @@ html_static_path = ['../theme']
# Trick for having ReadTheDocs read custom theme changes
# Trick for having ReadTheDocs read custom theme changes
def setup(app):
def setup(app):
app.add_stylesheet("css/custom.css")
app.add_css_file("css/custom.css")
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#
# html_extra_path = []
# If not None, a 'Last updated on:' timestamp is inserted at every page
# bottom, using the given strftime format.
# The empty string is equivalent to '%b %d, %Y'.
#
# html_last_updated_fmt = None
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#
# html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#
# html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#
# html_additional_pages = {}
# If false, no module index is generated.
#
# html_domain_indices = True
# If false, no index is generated.
#
# html_use_index = True
# If true, the index is split into individual pages for each letter.
#
# html_split_index = False
# If true, links to the reST sources are added to the pages.
#
html_show_sourcelink = False
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#
#
...
@@ -218,39 +114,9 @@ html_show_sphinx = False
...
@@ -218,39 +114,9 @@ html_show_sphinx = False
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#
#
# html_show_copyright = True
html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#
# html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
# html_file_suffix = None
# Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh'
#
# html_search_language = 'en'
# A dictionary with options for the search language support, empty by default.
# -- Options for LaTeX output ------------------------------------------------
# 'ja' uses this config value.
# 'zh' user can custom change `jieba` dictionary path.
#
# html_search_options = {'type': 'default'}
# The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used.
#
# html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder.
htmlhelp_basename = filename + 'doc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# The paper size ('letterpaper' or 'a4paper').
...
@@ -263,7 +129,10 @@ latex_elements = {
...
@@ -263,7 +129,10 @@ latex_elements = {
# Additional stuff for the LaTeX preamble.
# Additional stuff for the LaTeX preamble.
#
#
'preamble': '\usepackage{amssymb}',
'preamble': r'''
\usepackage{amssymb}
\newcommand{\DUrolecredits}{\footnotesize\color{lightgray}\newline}
''',
# Latex figure (float) alignment
# Latex figure (float) alignment
#
#
...
@@ -311,7 +180,7 @@ latex_show_urls = 'footnote'
...
@@ -311,7 +180,7 @@ latex_show_urls = 'footnote'
# latex_domain_indices = True
# latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# -- Options for manual page output ---------------------------------------
---
# One entry per manual page. List of tuples
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
# (source start file, name, description, authors, manual section).
...
@@ -325,7 +194,7 @@ man_pages = [
...
@@ -325,7 +194,7 @@ man_pages = [
# man_show_urls = False
# man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
# -- Options for Texinfo output -------------------------------------------
---
# Grouping the document tree into Texinfo files. List of tuples
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# (source start file, target name, title, author,
...
@@ -353,7 +222,7 @@ texinfo_documents = [
...
@@ -353,7 +222,7 @@ texinfo_documents = [
# texinfo_no_detailmenu = False
# texinfo_no_detailmenu = False
# -- Options for Epub output ----------------------------------------------
# -- Options for Epub output ----------------------------------------------
---
# Bibliographic Dublin Core info.
# Bibliographic Dublin Core info.
epub_title = project
epub_title = project
...
@@ -437,74 +306,13 @@ epub_exclude_files = ['search.html']
...
@@ -437,74 +306,13 @@ epub_exclude_files = ['search.html']
#
#
# epub_use_index = True
# epub_use_index = True
# -- Extension configurations ------------------------------------------------
# -- Options for todo extension ----------------------------------------------
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
# Example configuration for intersphinx: refer to the Python standard library.
# -- Options for pybtex ------------------------------------------------------
intersphinx_mapping = {'https://docs.python.org/': None}
bibtex_bibfiles = ['references.bib']
# -- Options for pybtex ----------------------------------------------
from pybtex.style.formatting.unsrt import Style as UnsrtStyle, date, pages, toplevel
from pybtex.style.template import * # ... and anything else needed
from pybtex.plugin import register_plugin
class ADSArxivStyle(UnsrtStyle):
def format_article(self, e):
volume_and_pages = first_of [
# volume and pages, with optional issue number
optional [
join [
field('volume'),
optional['(', field('number'),')'],
':', pages
],
],
# pages only
words ['pages', pages],
]
myurl = first_of [
optional_field('adsurl'),
join ['http://arxiv.org/abs/', optional_field('eprint')],
optional_field('url'),
optional [join ['http://dx.doi.org/', field('doi')]]
]
template = toplevel [
self.format_names('author'),
href [myurl, self.format_title(e, 'title')] \
if len(myurl.format_data(e)) > 0 \
else tag('strong') [self.format_title(e, 'title')],
sentence(capfirst=False) [
tag('emph') [field('journal')],
optional[ volume_and_pages ],
field('year')],
sentence(capfirst=False) [ optional_field('note') ],
]
return template.format_data(e)
def format_inproceedings(self, e):
myurl = first_of [
optional_field('adsurl'),
optional [join ['http://arxiv.org/abs/', field('eprint')]],
optional_field('url'),
optional [join ['http://dx.doi.org/', field('doi')]]
]
template = toplevel [
sentence [self.format_names('author')],
href [myurl, self.format_title(e, 'title')] \
if len(myurl.format_data(e)) > 0 \
else tag('strong') [self.format_title(e, 'title')],
words [
'In',
sentence(capfirst=False) [
optional[ self.format_editor(e, as_sentence=False) ],
self.format_btitle(e, 'booktitle', as_sentence=False),
self.format_volume_and_series(e, as_sentence=False),
optional[ pages ],
],
self.format_address_organization_publisher_date(e),
],
sentence(capfirst=False) [ optional_field('note') ],
]
return template.format_data(e)
register_plugin('pybtex.style.formatting', 'adsarxiv', ADSArxivStyle)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment