This repository has been archived by the owner on Mar 10, 2020. It is now read-only.
forked from navdeep-G/samplemod
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
516 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[report] | ||
omit = | ||
*/python?.?/* | ||
*__init__* | ||
tests/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
service_name: travis-ci | ||
repo_token: d9edOeB1k2fIKJMosheHF3jpxYJxxpuid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[flake8] | ||
exclude = __init__.py, docs/, build/, setup.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,3 +89,5 @@ ENV/ | |
# Rope project settings | ||
.ropeproject | ||
MANIFEST | ||
|
||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,6 @@ before_script: | |
|
||
script: | ||
- make test | ||
|
||
after_success: | ||
- coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
[![Build Status](https://travis-ci.org/cmccandless/markdown-generator.svg?branch=master)](https://travis-ci.org/cmccandless/markdown-generator) | ||
[![Coverage Status](https://coveralls.io/repos/github/cmccandless/markdown-generator/badge.svg?branch=master)](https://coveralls.io/github/cmccandless/markdown-generator?branch=master) | ||
|
||
Markdown Generator | ||
======================== | ||
|
||
Python module for generator GitHub-flavored markdown | ||
|
||
pip install markdown-generator | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,7 @@ | ||
class ColumnAlignment(object): | ||
def __init__(self, value): | ||
self.value = value | ||
from enum import IntEnum | ||
|
||
def has_flag(self, flag): | ||
if isinstance(flag, ColumnAlignment): | ||
return self.value & flag.value > 0 | ||
elif isinstance(flag, int): | ||
return self.value & flag > 0 | ||
return False | ||
|
||
def __eq__(self, other): | ||
if isinstance(other, ColumnAlignment): | ||
return self.value == other.value | ||
elif isinstance(other, int): | ||
return self.value == other | ||
return False | ||
|
||
|
||
LEFT = ColumnAlignment(1) | ||
RIGHT = ColumnAlignment(2) | ||
CENTER = ColumnAlignment(3) | ||
class Alignment(IntEnum): | ||
LEFT = 1 | ||
RIGHT = 2 | ||
CENTER = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
def link(url, text=None): | ||
if url: | ||
if text: | ||
return '[{}]({})'.format(text, url) | ||
return url | ||
return '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
flake8==3.5.0 | ||
pep8>1.7,<1.7.99 | ||
pyflakes==1.6.0 | ||
nose==1.3.7 | ||
ddt==1.1.1 | ||
coveralls>=1.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import unittest | ||
|
||
|
||
class MarkdownTestCase(unittest.TestCase): | ||
def assertRenderedEqual(self, obj, expected): | ||
return self.assertEqual(str(obj), expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import unittest | ||
|
||
from markdown_generator import Alignment | ||
|
||
|
||
class AlignmentTest(unittest.TestCase): | ||
def test_alignment_none(self): | ||
with self.assertRaises(ValueError): | ||
Alignment(None) | ||
|
||
def test_alignment_from_value(self): | ||
self.assertEqual(Alignment(1), 1) | ||
|
||
def test_invalid_alignment(self): | ||
with self.assertRaises(ValueError): | ||
Alignment(999) | ||
|
||
def test_left_or_right_is_center(self): | ||
self.assertEqual(Alignment.LEFT | Alignment.RIGHT, Alignment.CENTER) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from .helper import MarkdownTestCase | ||
|
||
from markdown_generator import BlockQuote | ||
|
||
|
||
class TestBlockQuote(MarkdownTestCase): | ||
def assertRenderedEqual(self, bq, expected): | ||
self.assertEqual(str(bq), expected) | ||
|
||
def test_empty(self): | ||
self.assertRenderedEqual(BlockQuote(), '') | ||
|
||
def test_single_line(self): | ||
bq = BlockQuote() | ||
bq.append('My quote here') | ||
self.assertRenderedEqual(bq, '> My quote here\n\n') | ||
|
||
def test_multiple_lines(self): | ||
bq = BlockQuote() | ||
bq.append('My quote here') | ||
bq.append('Longer quote') | ||
bq.append('Even longer') | ||
expected = ('> My quote here\n' | ||
'> Longer quote\n' | ||
'> Even longer\n\n') | ||
self.assertRenderedEqual(bq, expected) | ||
|
||
def test_level_other_than_one_empty(self): | ||
self.assertRenderedEqual(BlockQuote(2), '') | ||
|
||
def test_level_other_than_one_single_line(self): | ||
bq = BlockQuote(3) | ||
bq.append('My quote here') | ||
self.assertRenderedEqual(bq, '>>> My quote here\n\n') | ||
|
||
def test_level_other_than_one_multi_line(self): | ||
bq = BlockQuote(2) | ||
bq.append('My quote here') | ||
bq.append('Longer quote') | ||
bq.append('Even longer') | ||
expected = ('>> My quote here\n' | ||
'>> Longer quote\n' | ||
'>> Even longer\n\n') | ||
self.assertRenderedEqual(bq, expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from .helper import MarkdownTestCase | ||
|
||
from markdown_generator import Code | ||
|
||
|
||
class CodeTest(MarkdownTestCase): | ||
def test_empty(self): | ||
self.assertRenderedEqual(Code(), '') | ||
|
||
def test_empty_with_language(self): | ||
code = Code('Python') | ||
self.assertRenderedEqual(code, '') | ||
|
||
def test_single_line(self): | ||
code = Code() | ||
code.append('print("test")') | ||
self.assertRenderedEqual(code, '```\nprint("test")\n```\n') | ||
|
||
def test_single_line_with_language(self): | ||
code = Code('Python') | ||
code.append('print("test")') | ||
self.assertRenderedEqual(code, '```Python\nprint("test")\n```\n') | ||
|
||
def test_multiple_lines(self): | ||
code = Code() | ||
code.append('print("test")') | ||
code.append('print("test2")') | ||
self.assertRenderedEqual( | ||
code, | ||
'```\nprint("test")\nprint("test2")\n```\n' | ||
) | ||
|
||
def test_multiple_lines_with_language(self): | ||
code = Code('Python') | ||
code.append('print("test")') | ||
code.append('print("test2")') | ||
self.assertRenderedEqual( | ||
code, | ||
'```Python\nprint("test")\nprint("test2")\n```\n' | ||
) |
Oops, something went wrong.