remove warnings from using deprecated methods of Sphinx application

Use the sphinx wrapper around logging instead of app.info().

Add a -v option to sphinx-build to see the output.

Change-Id: Ia698929c252a2a19da812e399011341a41976540
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2018-10-09 10:46:37 -04:00
parent 0d86361c37
commit 7d3fc1b7a1
4 changed files with 32 additions and 29 deletions

View File

@ -7,8 +7,11 @@ from docutils.io import FileOutput
from docutils import nodes
from docutils.parsers import rst
import icalendar
from sphinx.util import logging
import yaml
LOG = logging.getLogger(__name__)
class PendingICS(nodes.Element):
@ -87,7 +90,7 @@ def doctree_resolved(app, doctree, docname):
series_name = node._series_name
data = node._data
app.info('building {} calendar'.format(series_name))
LOG.info('building {} calendar'.format(series_name))
cal = icalendar.Calendar()
cal.add('prodid', '-//releases.openstack.org//EN')
@ -111,7 +114,7 @@ def doctree_resolved(app, doctree, docname):
# ugly, but given the complexity of the expression
# above there are a bunch of ways things might
# fail.
app.info('could not get title for {}: {}'.format(item, e))
LOG.info('could not get title for {}: {}'.format(item, e))
title = item
summary.append(title)
if summary:
@ -159,7 +162,7 @@ def doctree_resolved(app, doctree, docname):
destination_path=output_full_name,
encoding='utf-8',
)
app.info('generating {}'.format(output_full_name))
LOG.info('generating {}'.format(output_full_name))
destination.write(cal.to_ical())
# Remove the node that the writer won't understand.
@ -181,12 +184,12 @@ def build_finished(app, exception):
destination_path=output_full_name,
encoding='utf-8',
)
app.info('generating {}'.format(output_full_name))
LOG.info('generating {}'.format(output_full_name))
destination.write(_global_calendar.to_ical())
def setup(app):
app.info('initializing ICS extension')
LOG.info('initializing ICS extension')
app.add_directive('ics', ICS)
app.connect('doctree-resolved', doctree_resolved)
app.connect('build-finished', build_finished)

View File

@ -4,6 +4,10 @@ import datetime
import os
import sys
from sphinx.util import logging
LOG = logging.getLogger(__name__)
# If extensions (or modules to document with autodoc) are in another directory,
# 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.
@ -90,5 +94,5 @@ def builder_inited(app):
def setup(app):
app.info('initializing from conf.py')
LOG.info('initializing from conf.py')
app.connect('builder-inited', builder_inited)

View File

@ -21,6 +21,7 @@ from docutils import nodes
from docutils.parsers import rst
from docutils.parsers.rst import directives
from docutils.statemachine import ViewList
from sphinx.util import logging
from sphinx.util.nodes import nested_parse_with_titles
from openstack_releases import deliverable
@ -28,6 +29,7 @@ from openstack_releases import governance
from openstack_releases import links
from openstack_releases import series_status
LOG = logging.getLogger(__name__)
_TEAM_DATA = governance.get_team_data()
_PHASE_DOC_URL = 'https://docs.openstack.org/project-team-guide/stable-branches.html#maintenance-phases' # noqa
@ -73,9 +75,11 @@ def _get_category(deliv):
_deliverables = None
def _initialize_deliverable_data(app):
def _initialize_deliverable_data():
global _deliverables
LOG.info('Loading deliverable data...')
series_status_data = series_status.SeriesStatus.from_directory(
'deliverables')
deliverable.Deliverable.init_series_status_data(series_status_data)
@ -100,9 +104,6 @@ class DeliverableDirectiveBase(rst.Directive):
]
def run(self):
env = self.state.document.settings.env
app = env.app
# The series value is optional for some directives. If it is
# present but an empty string, convert to None so the
# Deliverables class will treat it like a wildcard.
@ -131,7 +132,6 @@ class DeliverableDirectiveBase(rst.Directive):
None,
d,
s,
app,
result,
)
else:
@ -160,14 +160,13 @@ class DeliverableDirectiveBase(rst.Directive):
]
for category in self._CATEGORY_ORDER:
if category not in by_category:
app.info('No %r for %s' % (category,
(self.team_name, series)))
LOG.info('[sphinxext] No %r for %s', category,
(self.team_name, series))
continue
self._add_deliverables(
category,
by_category[category],
series,
app,
result,
)
@ -189,7 +188,7 @@ class DeliverableDirectiveBase(rst.Directive):
'tempest-plugin': 'Tempest Plugins',
}
def _add_deliverables(self, type_tag, deliverables, series, app, result):
def _add_deliverables(self, type_tag, deliverables, series, result):
source_name = '<' + __name__ + '>'
# expand any generators passed in and filter out deliverables
@ -220,7 +219,7 @@ class DeliverableDirectiveBase(rst.Directive):
# Determine the most recent release that is not an EOL
# tag.
for r in reversed(deliv.releases):
if not r.is_eol:
if not (r.is_eol or r.is_em):
recent_version = r.version
break
ref = ':ref:`%s-%s`' % (series, deliv.name)
@ -275,8 +274,8 @@ class DeliverableDirectiveBase(rst.Directive):
_title(deliv.name, '=')
app.info('[deliverables] rendering %s (%s)' %
(deliv.name, series))
LOG.info('[deliverables] rendering %s (%s)',
deliv.name, series)
release_notes = deliv.release_notes
if not release_notes:
@ -388,10 +387,10 @@ class TeamDirective(rst.Directive):
return node.children
def _generate_team_pages(app):
def _generate_team_pages():
teams_with_deliverables = list(sorted(_deliverables.get_teams()))
for team_name in teams_with_deliverables:
app.info('[team page] %s' % team_name)
LOG.info('[team page] %s', team_name)
slug = team_name.lower().replace('-', '_').replace(' ', '_')
base_file = slug + '.rst'
with open(os.path.join('doc/source/teams', base_file), 'w') as f:
@ -428,15 +427,12 @@ class HighlightsDirective(rst.Directive):
return series_highlights
def run(self):
env = self.state.document.settings.env
app = env.app
# Get the series we are reporting on
series = self.options.get('series')
if not series:
raise self.error('series value must be set to a valid cycle name.')
app.info('[series-highlights] gathering highlights for {}'.format(
LOG.info('[series-highlights] gathering highlights for {}'.format(
series))
result = ViewList()
@ -444,8 +440,8 @@ class HighlightsDirective(rst.Directive):
source_name = '<{}>'.format(__name__)
for team in sorted(series_highlights.keys(), key=lambda x: x.lower()):
app.info('[highlights] rendering %s highlights for %s' %
(team.title(), series))
LOG.info('[highlights] rendering %s highlights for %s',
team.title(), series)
tdata = _TEAM_DATA.get(team, {})
title = team.title()
@ -472,10 +468,10 @@ class HighlightsDirective(rst.Directive):
def setup(app):
_initialize_deliverable_data(app)
_initialize_deliverable_data()
app.add_directive('deliverable', DeliverableDirective)
app.add_directive('independent-deliverables',
IndependentDeliverablesDirective)
app.add_directive('team', TeamDirective)
app.add_directive('serieshighlights', HighlightsDirective)
_generate_team_pages(app)
_generate_team_pages()

View File

@ -66,7 +66,7 @@ deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/doc/requirements.txt
commands =
sphinx-build -a -E -W -d doc/build/doctrees -b html doc/source doc/build/html
sphinx-build -v -a -E -W -d doc/build/doctrees -b html doc/source doc/build/html
whereto {toxinidir}/doc/source/_extra/.htaccess {toxinidir}/doc/test/redirect-tests.txt
[flake8]