Skip to content

Commit

Permalink
cmark-format: Initial work on a formatting tool.
Browse files Browse the repository at this point in the history
The only implemented feature is reindenting to arbitrary width,
but that was also the actually complicated one so there's that.
  • Loading branch information
MathieuDuponchelle committed Jan 6, 2017
1 parent a44cfaf commit 014b781
Show file tree
Hide file tree
Showing 5 changed files with 540 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ include_directories(. ${CMAKE_CURRENT_BINARY_DIR})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmark_version.h.in
${CMAKE_CURRENT_BINARY_DIR}/cmark_version.h)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmark-format.in
${CMAKE_CURRENT_BINARY_DIR}/cmark-format)

include (GenerateExportHeader)

add_executable(${PROGRAM} ${PROGRAM_SOURCES})
Expand Down
24 changes: 24 additions & 0 deletions src/cmark-format.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python3

import os
import sys
import argparse

HERE = "@CMAKE_CURRENT_SOURCE_DIR@"
sys.path.append(HERE)
sys.path.append(os.path.join(HERE, os.pardir, 'wrappers'))

from remarkor import *
from wrapper import conf

conf.set_library_path("@CMAKE_CURRENT_BINARY_DIR@")

if __name__=='__main__':
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument('input')
arg_parser.add_argument('--width', type=int, default=80)
args = arg_parser.parse_args()

remarkor = Remarkor.from_filename(args.input)
res = remarkor.remark(width=args.width)
sys.stdout.write(res)
Loading

0 comments on commit 014b781

Please sign in to comment.