diff options
| -rwxr-xr-x | pocco (renamed from pocco.py) | 23 | ||||
| -rw-r--r-- | setup.py | 10 | 
2 files changed, 29 insertions, 4 deletions
@@ -45,12 +45,13 @@ def generate_documentation(source):  #  def parse(source, code):      lines = code.split("\n") -    if lines[0].startswith("#!"): -        lines.pop(0)      sections = []      language = get_language(source)      has_code = docs_text = code_text = "" +    if lines[0].startswith("#!"): +        lines.pop(0) +      def save(docs, code):          sections.append({              "docs_text": docs, @@ -148,12 +149,26 @@ for ext, l in languages.items():  # Get the current language we're documenting, based on the extension.  def get_language(source): -    return languages[ source[source.rindex("."):] ] +    try: +        return languages[ source[source.rindex("."):] ] +    except ValueError: +        source = open(source, "r") +        code = source.read() +        source.close() +        lang = lexers.guess_lexer(code).name.lower() +        for l in languages.values(): +            if l["name"] == lang: +                return l +        else: +            raise ValueError("Can't figure out the language!")  # Compute the destination HTML path for an input source file path. If the source  # is `lib/example.py`, the HTML will be at `docs/example.html`  def destination(filepath): -    name = filepath.replace(filepath[ filepath.rindex("."): ], "") +    try: +        name = filepath.replace(filepath[ filepath.rindex("."): ], "") +    except ValueError: +        name = filepath      return "docs/" + path.basename(name) + ".html"  # Shift items off the front of the `list` until it is empty, then return diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..f359b6d --- /dev/null +++ b/setup.py @@ -0,0 +1,10 @@ +from setuptools import setup + +setup(name="Pocco", +      version="0.1", +      description="""A Python port of Docco: the original quick-and-dirty, hundred-line-long, +      literate-programming-style documentation generator.""", +      author="Nick Fitzgerald", +      author_email="fitzgen@gmail.com", +      url="http://fitzgen.github.com/pocco", +      scripts=["pocco"])  | 
