Skip to content

Commit

Permalink
Merge pull request #567 from Carreau/changelog-2
Browse files Browse the repository at this point in the history
fixup changelog
  • Loading branch information
Carreau committed Jun 11, 2020
2 parents 1c8d91a + d0eb76c commit 290a6fc
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 20 deletions.
29 changes: 13 additions & 16 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@ Changes in Traitlets
Traitlets 5.0
-------------

:ghpull:`319` adds ability to introduce both shot and long version of aliases, allowing for short and long options ``-``
and ``--``.
:ghpull:`362` , ghpull:`361` introduces:
- help for aliases , aliases dict values can now be a tuple with ('target', 'help string')
- subcommands can now be arbitrary callable and do not need to be subclass of `Application`
:ghpull:`333` introduces a `Callable` trait.
:ghpull:`371` introduces a `FuzzyEnum` trait that allow case insensitive and unique prefix matching.
:ghpull:`509` remove all base ``except:`` meaning traitlets will not catch a number of `BaseException` s anymore.
:ghpull:`438` introduces ``.info_rst()`` to let traitlets overwrite the automatically generated rst documentation.
:ghpull:`402` rewrite handling of error messages for nested traits.
:ghpull:`322` rewrite commandline argument parsing to use argparse, and allow more flexibility in assingin literals
without quoting.
:ghpull:`341` introduces ``--Application.show_config=True`` which will make by default any application show it
configuration, all the files it loaded configuration from, and exit.
:ghpull:`340` Old way of passing containers in the command line is now deprecated, and will emit warnign on the command
line.
- :ghpull:`319` adds ability to introduce both shot and long version of aliases, allowing for short and long options ``-`` and ``--``.
- :ghpull:`362` , :ghpull:`361` introduces:
- help for aliases , aliases dict values can now be a tuple with ('target', 'help string')
- subcommands can now be arbitrary callable and do not need to be subclass of :any:`Application`
- :ghpull:`333` introduces a :any:`Callable` trait.
- :ghpull:`371` introduces a :any:`FuzzyEnum` trait that allow case insensitive and unique prefix matching.
- :ghpull:`509` remove all base ``except:`` meaning traitlets will not catch a number of :any:`BaseException` s anymore.
- :ghpull:`438` introduces ``.info_rst()`` to let traitlets overwrite the automatically generated rst documentation.
- :ghpull:`402` rewrite handling of error messages for nested traits.
- :ghpull:`322` rewrite command line argument parsing to use argparse, and allow more flexibility in assigning literals without quoting.
- :ghpull:`341` introduces ``--Application.show_config=True`` which will make by default any application show it
- configuration, all the files it loaded configuration from, and exit.
- :ghpull:`340` Old way of passing containers in the command line is now deprecated, and will emit warning on the command line.


4.3
Expand Down
11 changes: 7 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
sys.path.insert(0, os.path.abspath("../sphinxext"))
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.napoleon',
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"github", # for easy GitHub links
]
github_project_url = "https://github.com/ipython/traitlets"

# Add any paths that contain templates here, relative to this directory.
# templates_path = ['_templates']
Expand Down Expand Up @@ -322,4 +325,4 @@
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
# otherwise, readthedocs.org uses their theme by default, so no need to specify it
# otherwise, readthedocs.org uses their theme by default, so no need to specify it
160 changes: 160 additions & 0 deletions docs/sphinxext/github.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
"""Define text roles for GitHub
* ghissue - Issue
* ghpull - Pull Request
* ghuser - User
Adapted from bitbucket example here:
https://bitbucket.org/birkenfeld/sphinx-contrib/src/tip/bitbucket/sphinxcontrib/bitbucket.py
Authors
-------
* Doug Hellmann
* Min RK
"""
#
# Original Copyright (c) 2010 Doug Hellmann. All rights reserved.
#

from docutils import nodes, utils
from docutils.parsers.rst.roles import set_classes
from sphinx.util.logging import getLogger

info = getLogger(__name__).info

def make_link_node(rawtext, app, type, slug, options):
"""Create a link to a github resource.
:param rawtext: Text being replaced with link node.
:param app: Sphinx application context
:param type: Link type (issues, changeset, etc.)
:param slug: ID of the thing to link to
:param options: Options dictionary passed to role func.
"""

try:
base = app.config.github_project_url
if not base:
raise AttributeError
if not base.endswith('/'):
base += '/'
except AttributeError as err:
raise ValueError('github_project_url configuration value is not set (%s)' % str(err))

ref = base + type + '/' + slug + '/'
set_classes(options)
prefix = "#"
if type == 'pull':
prefix = "PR " + prefix
node = nodes.reference(rawtext, prefix + utils.unescape(slug), refuri=ref,
**options)
return node

def ghissue_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
"""Link to a GitHub issue.
Returns 2 part tuple containing list of nodes to insert into the
document and a list of system messages. Both are allowed to be
empty.
:param name: The role name used in the document.
:param rawtext: The entire markup snippet, with role.
:param text: The text marked with the role.
:param lineno: The line number where rawtext appears in the input.
:param inliner: The inliner instance that called us.
:param options: Directive options for customization.
:param content: The directive content for customization.
"""

try:
issue_num = int(text)
if issue_num <= 0:
raise ValueError
except ValueError:
msg = inliner.reporter.error(
'GitHub issue number must be a number greater than or equal to 1; '
'"%s" is invalid.' % text, line=lineno)
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
app = inliner.document.settings.env.app
#info('issue %r' % text)
if 'pull' in name.lower():
category = 'pull'
elif 'issue' in name.lower():
category = 'issues'
else:
msg = inliner.reporter.error(
'GitHub roles include "ghpull" and "ghissue", '
'"%s" is invalid.' % name, line=lineno)
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
node = make_link_node(rawtext, app, category, str(issue_num), options)
return [node], []

def ghuser_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
"""Link to a GitHub user.
Returns 2 part tuple containing list of nodes to insert into the
document and a list of system messages. Both are allowed to be
empty.
:param name: The role name used in the document.
:param rawtext: The entire markup snippet, with role.
:param text: The text marked with the role.
:param lineno: The line number where rawtext appears in the input.
:param inliner: The inliner instance that called us.
:param options: Directive options for customization.
:param content: The directive content for customization.
"""
app = inliner.document.settings.env.app
#info('user link %r' % text)
ref = 'https://www.github.com/' + text
node = nodes.reference(rawtext, text, refuri=ref, **options)
return [node], []

def ghcommit_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
"""Link to a GitHub commit.
Returns 2 part tuple containing list of nodes to insert into the
document and a list of system messages. Both are allowed to be
empty.
:param name: The role name used in the document.
:param rawtext: The entire markup snippet, with role.
:param text: The text marked with the role.
:param lineno: The line number where rawtext appears in the input.
:param inliner: The inliner instance that called us.
:param options: Directive options for customization.
:param content: The directive content for customization.
"""
app = inliner.document.settings.env.app
#info('user link %r' % text)
try:
base = app.config.github_project_url
if not base:
raise AttributeError
if not base.endswith('/'):
base += '/'
except AttributeError as err:
raise ValueError('github_project_url configuration value is not set (%s)' % str(err))

ref = base + text
node = nodes.reference(rawtext, text[:6], refuri=ref, **options)
return [node], []


def setup(app):
"""Install the plugin.
:param app: Sphinx application context.
"""
info('Initializing GitHub plugin')
app.add_role('ghissue', ghissue_role)
app.add_role('ghpull', ghissue_role)
app.add_role('ghuser', ghuser_role)
app.add_role('ghcommit', ghcommit_role)
app.add_config_value('github_project_url', None, 'env')

metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
return metadata

0 comments on commit 290a6fc

Please sign in to comment.