diff options
-rwxr-xr-x | unperish | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -24,6 +24,7 @@ import logging import os import shutil import subprocess +import tempfile __version__ = '0.0' @@ -234,18 +235,30 @@ class Unperish(cliapp.Application): def cmd_publish_docs(self, args): '''Publish docs related to this project.''' + + def publish(source, target_base): + target = os.path.join(self.settings['web-directory'], target_base) + if self.settings['verbose']: + print 'Copying %s to %s' % (source, target) + shutil.copyfile(source, target) if not self.settings['web-directory']: raise cliapp.AppException('Need --web-directory ' 'for publish-docs.') + docs = ['README', 'NEWS'] for doc in docs: if os.path.exists(doc): - target = os.path.join(self.settings['web-directory'], - doc + '.mdwn') - if self.settings['verbose']: - print 'Copying %s to %s' % (doc, target) - shutil.copyfile(doc, target) + publish(doc, doc + '.mdwn') + + for manpage in glob.glob('*.[1-8]'): + fmt = self.runcmd(['man', '-l', manpage]) + text = self.runcmd(['col', '-b'], stdin=fmt) + fd, name = tempfile.mkstemp() + os.write(fd, text) + os.close(fd) + publish(name, manpage + '.txt') + os.remove(name) def cmd_clean(self, args): '''Clean up the build-area (remove everything except the dir).''' |