Skip to content
Snippets Groups Projects
Commit e3766c5e authored by anarcat's avatar anarcat
Browse files

preliminary attempt at debian changelog support for sphinx

abandoned because of limited flexibility of debian changelog parser:
it only shows the changelog lines as, well, lines (no parsing of *)

we would need to improve on the changelog parsing library, something i
don't quite feel like getting into right now.
parent 5b1f5998
No related tags found
No related merge requests found
......@@ -5,11 +5,13 @@
import os
import datetime
import time
from docutils import parsers, nodes
from distutils.command.build import build
from distutils.core import Command
from distutils.errors import DistutilsOptionError
import subprocess # nosec
from debian import changelog
class build_slides(Command):
......@@ -35,6 +37,25 @@ def has_rst2s5(build):
"""predicate for this class: do not fail if rst2s5 is missing"""
return (os.system('rst2s5 < /dev/null > /dev/null') == 0) # nosec
class DebianChangelogParser(parsers.Parser):
def parse(self, inputstring, document):
self.setup_parse(inputstring, document)
self.document = document
self.current_node = document
for block in changelog.Changelog(inputstring):
self.verbatim("\n".join(block.changes()))
self.finish_parse()
def verbatim(self, text):
verbatim_node = nodes.literal_block()
text = ''.join(text)
if text.endswith('\n'):
text = text[:-1]
verbatim_node.append(nodes.Text(text, text))
self.current_node.append(verbatim_node)
# (function, predicate), see http://docs.python.org/2/distutils/apiref.html#distutils.cmd.Command.sub_commands
build.sub_commands.append(('build_slides', has_rst2s5))
build.sub_commands.append(('build_sphinx', None))
#!/usr/bin/python
# -*- coding: utf-8 -*-
import unittest
from docutils.core import publish_parts
from monkeysign.documentation import DebianChangelogParser
class TestBootstrap(unittest.TestCase):
def test_basic_parser(self):
source = 'foo'
ret = publish_parts(source=source, writer_name='html',
parser=DebianChangelogParser())
self.assertIn('foo', ret['body'])
def test_basic_parser(self):
source = '''
monkeysign (2.2.0) unstable; urgency=medium
* fix tests with Debian CI
* fix FTBS errors in reproducible builds due to test suite failing in
the future
* do not STARTTLS on already secure (TLS) connexions
* enable tor support with --tor flag
* handle SMTP conversations better
-- Antoine Beaupré <anarcat@debian.org> Tue, 11 Oct 2016 11:29:10 -0400
'''
ret = publish_parts(source=source, writer_name='html',
parser=DebianChangelogParser())
self.assertIn('STARTTLS', ret['body'])
if __name__ == '__main__':
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment