aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Fitzgerald <fitzgen@gmail.com>2010-06-29 21:18:53 -0700
committerNick Fitzgerald <fitzgen@gmail.com>2010-06-29 21:18:53 -0700
commit993fbde068c7cad977aa2be857237f6ab7d018f1 (patch)
tree6162725ff340ccd8d3d0c41969545ad835305f13
parentd22799ca1d63e55d88fe0a3adf4c71904a591012 (diff)
downloadpycco-993fbde068c7cad977aa2be857237f6ab7d018f1.tar.gz
pycco-993fbde068c7cad977aa2be857237f6ab7d018f1.zip
Fixing up pocco to work with files that dont have an extension and adding the setup.py script
-rwxr-xr-xpocco (renamed from pocco.py)23
-rw-r--r--setup.py10
2 files changed, 29 insertions, 4 deletions
diff --git a/pocco.py b/pocco
index 667238e..10affd7 100755
--- a/pocco.py
+++ b/pocco
@@ -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"])