commit 701657e54b450e5c9ca8dd2a7a6c5029fecd0996 Author: Martin A. Brown Date: Wed Feb 10 19:22:23 2016 -0800 initial commit diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..5d69ab9 --- /dev/null +++ b/README.rst @@ -0,0 +1,31 @@ +tldp - tools for publishing from TLDP sources +============================================= + +TLDP = The Linux Documentation Project. +These are a set of scripts that process committed documents in the +TLDP document source repository to an output tree of choice. + +Installation +------------ + +You can install, upgrade, uninstall tldp tools with these commands:: + + $ pip install tldp + $ pip install --upgrade tldp + $ pip uninstall tldp + +There's also a package for Debian/Ubuntu, but it's not always the +latest version. + +Example usages: +--------------- + +FIXME: Missing examples. + +Links +----- + +* `Output documentation tree (sample) `_ + +* `Source tree on GitHub `_ + diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..999909d --- /dev/null +++ b/setup.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +import os + +from setuptools import setup, find_packages + + +with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as r_file: + readme = r_file.read() + + +setup( + name='tldp', + version='0.1', + license='GNU', + author='Martin A. Brown', + author_email='martin@linux-ip.net', + description='tools for processing all TLDP source documents', + long_description=readme, + packages=find_packages(), + test_suite='tests', + install_requires=[ + 'six>=1.7', + ], + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Topic :: Software Development :: Libraries :: Python Modules' + ], +) diff --git a/tldp/__init__.py b/tldp/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tldp/doctypes/__init__.py b/tldp/doctypes/__init__.py new file mode 100644 index 0000000..e068153 --- /dev/null +++ b/tldp/doctypes/__init__.py @@ -0,0 +1,7 @@ +from .text import Text +from .rst import RestructuredText +from .markdown import Markdown +from .linuxdoc import Linuxdoc +from .docbooksgml import DocbookSGML +from .docbook4xml import Docbook4XML +from .docbook5xml import Docbook5XML diff --git a/tldp/doctypes/common.py b/tldp/doctypes/common.py new file mode 100644 index 0000000..a66b890 --- /dev/null +++ b/tldp/doctypes/common.py @@ -0,0 +1,27 @@ +#! /usr/bin/python + +from __future__ import print_function + +import string +from ..utils import logger + + +class SignatureChecker(object): + + @classmethod + def signatureLocation(cls, name, fin): + fin.seek(0) + buf = fin.read(1024) + for sig in cls.signatures: + try: + sindex = string.index(buf.lower(), sig.lower()) + logger.debug("In file %s, signature %s found at %s; doctype %s found", + name, sig, sindex, cls) + return sindex + except ValueError: + logger.debug("In file %s, signature %s not found for document type %s", + name, sig, cls.__name__) + return None + +# +# -- end of file diff --git a/tldp/doctypes/docbook4xml.py b/tldp/doctypes/docbook4xml.py new file mode 100644 index 0000000..e4a3234 --- /dev/null +++ b/tldp/doctypes/docbook4xml.py @@ -0,0 +1,17 @@ +#! /usr/bin/python + +from ..utils import logger + +from .common import SignatureChecker + + +class Docbook4XML(SignatureChecker): + extensions = ['.xml'] + signatures = ['-//OASIS//DTD DocBook XML V4.1.2//EN', + '-//OASIS//DTD DocBook XML V4.2//EN', + '-//OASIS//DTD DocBook XML V4.2//EN', + '-//OASIS//DTD DocBook XML V4.4//EN', + '-//OASIS//DTD DocBook XML V4.5//EN', ] + +# +# -- end of file diff --git a/tldp/doctypes/docbook5xml.py b/tldp/doctypes/docbook5xml.py new file mode 100644 index 0000000..e2c5b27 --- /dev/null +++ b/tldp/doctypes/docbook5xml.py @@ -0,0 +1,13 @@ +#! /usr/bin/python + +from ..utils import logger +from .common import SignatureChecker + + +class Docbook5XML(SignatureChecker): + extensions = ['.xml'] + signatures = ['-//OASIS//DTD DocBook V5.0/EN', + 'http://docbook.org/ns/docbook', ] + +# +# -- end of file diff --git a/tldp/doctypes/docbooksgml.py b/tldp/doctypes/docbooksgml.py new file mode 100644 index 0000000..53d96a7 --- /dev/null +++ b/tldp/doctypes/docbooksgml.py @@ -0,0 +1,15 @@ +#! /usr/bin/python + +from ..utils import logger +from .common import SignatureChecker + + +class DocbookSGML(SignatureChecker): + extensions = ['.sgml'] + signatures = ['-//Davenport//DTD DocBook V3.0//EN', + '-//OASIS//DTD DocBook V3.1//EN', + '-//OASIS//DTD DocBook V4.1//EN', + '-//OASIS//DTD DocBook V4.2//EN', ] + +# +# -- end of file diff --git a/tldp/doctypes/linuxdoc.py b/tldp/doctypes/linuxdoc.py new file mode 100644 index 0000000..6cad33b --- /dev/null +++ b/tldp/doctypes/linuxdoc.py @@ -0,0 +1,24 @@ +#! /usr/bin/python + +from ..utils import logger +from .common import SignatureChecker + + +class Linuxdoc(SignatureChecker): + extensions = ['.sgml'] + signatures = ['