summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Trask <andrew.trask@digitalreasoning.com>2015-11-14 13:36:54 -0600
committerAndrew Trask <andrew.trask@digitalreasoning.com>2015-11-14 13:36:54 -0600
commit56ad80efa822e5e2d79e7fe3155cd5bb3931660c (patch)
treeeb636622ca391918382596aa47904c45e20ccc22
parent2ac3d174fbd0733653276baec324d239c81409dd (diff)
parentbbeee06f1222fa47439717d2e4b642a41e9d7f4b (diff)
downloadpycco-56ad80efa822e5e2d79e7fe3155cd5bb3931660c.tar.gz
merge
-rw-r--r--.gitignore10
-rw-r--r--.travis.yml12
-rw-r--r--pycco/main.py17
-rw-r--r--tests/test_pycco.py3
4 files changed, 40 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 07b20dd..e1c9655 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,13 @@
+.coverage
*.pyc
/Pycco.egg-info
build/*
dist/*
-docs/* \ No newline at end of file
+docs/*
+/tags
+
+.cache
+.hypothesis
+.ropeproject
+
+.DS_Store
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..62e7c6b
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,12 @@
+language: python
+python:
+ - '2.7'
+ - '3.5'
+install:
+ - 'pip install -r requirements.txt'
+ - 'pip install -r requirements.test.txt'
+script:
+ - 'py.test --cov=pycco tests/'
+ - 'python -m pycco.main pycco/main.py'
+after_success:
+ - coveralls
diff --git a/pycco/main.py b/pycco/main.py
index 676f6ff..bfce2ea 100644
--- a/pycco/main.py
+++ b/pycco/main.py
@@ -48,6 +48,7 @@ def generate_documentation(source, outdir=None, preserve_paths=True,
code = open(source, "rb").read().decode(encoding)
return _generate_documentation(source, code, outdir, preserve_paths, language)
+<<<<<<< HEAD
def _generate_documentation(file_path, code, outdir, preserve_paths, language):
"""
@@ -58,6 +59,18 @@ def _generate_documentation(file_path, code, outdir, preserve_paths, language):
highlight(sections, language, preserve_paths=preserve_paths, outdir=outdir)
return generate_html(file_path, sections, preserve_paths=preserve_paths, outdir=outdir)
+=======
+
+def _generate_documentation(file_path, code, outdir, preserve_paths, language):
+ """
+ Helper function to allow documentation generation without file handling.
+ """
+ language = get_language(file_path, code, language=language)
+ sections = parse(code, language)
+ highlight(sections, language, preserve_paths=preserve_paths, outdir=outdir)
+ return generate_html(file_path, sections, preserve_paths=preserve_paths, outdir=outdir)
+
+>>>>>>> bbeee06f1222fa47439717d2e4b642a41e9d7f4b
def parse(code, language):
"""
@@ -113,6 +126,7 @@ def parse(code, language):
and len(line.strip()) > len(multiend)):
multi_line = False
+
if((not line.strip().startswith(multistart) and not multi_line) or multi_string):
process_as_code = True
@@ -152,6 +166,7 @@ def parse(code, language):
process_as_code = True
if(process_as_code):
+
if code_text and any(line.lstrip().startswith(x)
for x in ['class ', 'def ', '@']):
if not code_text.lstrip().startswith("@"):
@@ -159,7 +174,7 @@ def parse(code, language):
code_text = has_code = docs_text = ''
has_code = True
- code_text += line + '\n'
+ code_text += line + '\n'
save(docs_text, code_text)
diff --git a/tests/test_pycco.py b/tests/test_pycco.py
index 6159cfd..2cc2b15 100644
--- a/tests/test_pycco.py
+++ b/tests/test_pycco.py
@@ -120,6 +120,7 @@ def test_generate_documentation():
def test_process(preserve_paths, choice):
lang_name = choice([l["name"] for l in p.languages.values()])
p.process([PYCCO_SOURCE], preserve_paths=preserve_paths, outdir=tempfile.gettempdir(), language=lang_name)
+<<<<<<< HEAD
def test_ensure_multiline_string_support():
@@ -139,3 +140,5 @@ def x():
assert docs_code_tuple_list[0]['docs_text'] == ''
assert "#" not in docs_code_tuple_list[1]['docs_text']
+=======
+>>>>>>> bbeee06f1222fa47439717d2e4b642a41e9d7f4b