Skip to content

Commit

Permalink
Add MarkdownfmtBear
Browse files Browse the repository at this point in the history
It suggests better formatting in markdown files.

Closes #1538
  • Loading branch information
naveentata committed Jul 20, 2017
1 parent 1156567 commit 47b2e0d
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions .ci/deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ go get -u sourcegraph.com/sqs/goreturns
go get -u golang.org/x/tools/cmd/gotype
go get -u github.com/kisielk/errcheck
go get -u github.com/BurntSushi/toml/cmd/tomlv
go get -u github.com/shurcooL/markdownfmt

# Ruby commands
bundle install --path=vendor/bundle --binstubs=vendor/bin --jobs=8 --retry=3
Expand Down
28 changes: 28 additions & 0 deletions bears/markdown/MarkdownfmtBear.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from coalib.bearlib.abstractions.Linter import linter
from dependency_management.requirements.GoRequirement import GoRequirement


@linter(executable='markdownfmt',
output_format='corrected',
result_message='Formatting can be improved.',
use_stdin=True)
class MarkdownfmtBear:
"""
Check and correct formatting of Markdown files using ``mardownfmt``.
Basic checks like alignment, indendation are provided.
Note that MarkdownfmtBear works only with pure Markdown files.
"""
LANGUAGES = {'Markdown'}
REQUIREMENTS = {GoRequirement(
package='github.com/shurcooL/markdownfmt')}
AUTHORS = {'The coala developers'}
AUTHORS_EMAILS = {'[email protected]'}
LICENSE = 'AGPL-3.0'
CAN_FIX = {'Formatting'}
ASCIINEMA_URL = 'https://asciinema.org/a/396jhuyw1j0c1l2i9p09wlhye'
SEE_MORE = 'https://github.com/shurcooL/markdownfmt'

@staticmethod
def create_arguments(filename, file, config_file):
return list()
32 changes: 32 additions & 0 deletions tests/markdown/MarkdownfmtBearTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from coalib.testing.LocalBearTestHelper import verify_local_bear

from bears.markdown.MarkdownfmtBear import MarkdownfmtBear

header_in_file1 = """
MarkdownBear
=====
"""

header_out_file1 = """
MarkdownBear
============
"""

spacing_in_file2 = """
This is a test file.
"""

spacing_out_file2 = """
This is a test file.
"""

MarkdownfmtBear = verify_local_bear(
MarkdownfmtBear,
valid_files=(header_in_file1, spacing_in_file2,),
invalid_files=(header_out_file1, spacing_out_file2,))

0 comments on commit 47b2e0d

Please sign in to comment.