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 4, 2017
1 parent 8d20150 commit ef34ee3
Show file tree
Hide file tree
Showing 5 changed files with 511 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 @@ -70,6 +70,9 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libcmark.pc.in
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcmark.pc
DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)

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 ef34ee3

Please sign in to comment.