Skip to content

Commit

Permalink
Merge pull request #35 from hartwork/manpage
Browse files Browse the repository at this point in the history
Add and ship AsciiDoc manpage, improve --help, add --version
  • Loading branch information
ralphbean committed Oct 1, 2013
2 parents b1ed96e + 2ec3630 commit ad608eb
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 13 deletions.
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
include README.rst
include LICENSE
include Makefile
include man/asciidoc.conf
include man/ansi2html.1
include man/ansi2html.1.txt
recursive-include tests *
29 changes: 25 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,41 @@
DESTDIR = /
SETUP_PY = ./setup.py

all:
A2X = a2x
PYTHON = python
RM = rm

GENERATED_FILES = man/ansi2html.1

_MANUAL_PACKAGE = ansi2html
_MANUAL_TITLE = ansi2html Manual
_MANUAL_VERSION = $(shell $(PYTHON) ansi2html/version.py)


all: $(GENERATED_FILES)
$(SETUP_PY) build

check:
check: $(GENERATED_FILES)
$(SETUP_PY) check
$(SETUP_PY) test

clean:
$(SETUP_PY) clean
$(RM) -f $(GENERATED_FILES)

dist:
dist: $(GENERATED_FILES)
$(SETUP_PY) sdist

install:
install: $(GENERATED_FILES)
$(SETUP_PY) install --root '$(DESTDIR)'

man/ansi2html.1: man/ansi2html.1.txt man/asciidoc.conf Makefile ansi2html/version.py
$(A2X) \
--conf-file=man/asciidoc.conf \
--attribute="manual_package=$(_MANUAL_PACKAGE)" \
--attribute="manual_title=$(_MANUAL_TITLE)" \
--attribute="manual_version=$(_MANUAL_VERSION)" \
--format=manpage -D man \
"$<"

.PHONY: all check clean dist install
17 changes: 9 additions & 8 deletions ansi2html/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from ordereddict import OrderedDict

from ansi2html.style import get_styles
from ansi2html.version import VERSION_STR
import six
from six.moves import map
from six.moves import zip
Expand Down Expand Up @@ -383,7 +384,7 @@ def main():
$ task burndown | ansi2html > burndown.html
"""

parser = optparse.OptionParser(usage=main.__doc__)
parser = optparse.OptionParser(usage=main.__doc__, version="%%prog %s" % VERSION_STR)
parser.add_option(
"-p", "--partial", dest="partial",
default=False, action="store_true",
Expand All @@ -397,7 +398,7 @@ def main():
default=False, action="store_true",
help="Just produce the <style> tag.")
parser.add_option(
"-f", '--font-size', dest='font_size',
"-f", '--font-size', dest='font_size', metavar='SIZE',
default="normal",
help="Set the global font size in the output.")
parser.add_option(
Expand All @@ -411,19 +412,19 @@ def main():
parser.add_option(
"-u", '--unescape', dest='escaped',
default=True, action="store_false",
help="Don't escape xml tags found in the input.")
help="Do not escape XML tags found in the input.")
parser.add_option(
"-m", '--markup-lines', dest="markup_lines",
default=False, action="store_true",
help="Surround lines with <span id='line-n'>...</span>.")
help="Surround lines with <span id='line-n'>..</span>.")
parser.add_option(
'--input-encoding', dest='input_encoding',
'--input-encoding', dest='input_encoding', metavar='ENCODING',
default='utf-8',
help="Input encoding")
help="Specify input encoding")
parser.add_option(
'--output-encoding', dest='output_encoding',
'--output-encoding', dest='output_encoding', metavar='ENCODING',
default='utf-8',
help="Output encoding")
help="Specify output encoding")

opts, args = parser.parse_args()

Expand Down
5 changes: 5 additions & 0 deletions ansi2html/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
VERSION = (0, 10, 0)
VERSION_STR = '.'.join([str(e) for e in VERSION])

if __name__ == '__main__':
print(VERSION_STR)
1 change: 1 addition & 0 deletions man/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/ansi2html.1
84 changes: 84 additions & 0 deletions man/ansi2html.1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
ANSI2HTML(1)
============
:doctype: manpage
:man source: {manual_package}
:man version: {manual_version}
:man manual: {manual_title}


NAME
----
ansi2html - Convert text with ANSI color codes to HTML


SYNOPSIS
--------
*ansi2html* ['OPTIONS'] [*--inline*] [*--partial*]


DESCRIPTION
-----------
Tool to convert text with ANSI color codes to HTML.


OPTIONS
-------

*-p*, *--partial*::
Process lines as them come in. No headers are produced.

*-i*, *--inline*::
Inline style without headers or template.

*-H*, *--headers*::
Just produce the "<style>" tag.

*-f* 'SIZE', *--font-size*='SIZE'::
Set the global font size in the output.

*-l*, *--light-background*::
Set output to "light background" mode.

*-a*, *--linkify*::
Transform URLs into "<a>" links.

*-u*, *--unescape*::
Do not escape XML tags found in the input.

*-m*, *--markup-lines*::
Surround lines with "`<span id='line-n'>..</span>`".

*--input-encoding='ENCODING'*::
Specify input encoding.

*--output-encoding='ENCODING'*::
Specify output encoding.

*-h*, *--help*::
Show this help message and exit.

*--version*::
Show program's version number and exit.


EXAMPLES
--------
-------------------
$ ls --color=always | ansi2html > directories.html

$ sudo tail /var/log/messages | ccze -A | ansi2html > logs.html

$ task burndown | ansi2html > burndown.html
-------------------


HOMEPAGE
--------
* GitHub: https://github.com/ralphbean/ansi2html
* PyPI: https://pypi.python.org/pypi/ansi2html


AUTHORS
-------
* Ralph Bean <rbean@redhat.com>
* Sebastian Pipping <sebastian@pipping.org>
Empty file added man/asciidoc.conf
Empty file.
10 changes: 9 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

import sys

sys.path.insert(0, '.')
from ansi2html.version import VERSION_STR

f = open('README.rst')
long_description = f.read().strip()
long_description = long_description.split('split here', 1)[1]
Expand All @@ -53,7 +56,7 @@

setup(
name='ansi2html',
version='0.10.0',
version=VERSION_STR,
description="Convert text with ANSI color codes to HTML",
long_description=long_description,
author='Ralph Bean',
Expand Down Expand Up @@ -83,6 +86,11 @@
],
test_suite='nose.collector',
packages=['ansi2html'],
data_files=[
('/usr/share/man/man1/', [
'man/ansi2html.1',
]),
],
include_package_data=True,
zip_safe=False,
entry_points="""
Expand Down

0 comments on commit ad608eb

Please sign in to comment.