Skip to content

Commit b18c103

Browse files
cmark-format: Initial work on a formatting tool.
The only implemented feature is reindenting to arbitrary width, but that was also the actually complicated one so there's that.
1 parent 8d20150 commit b18c103

File tree

5 files changed

+510
-0
lines changed

5 files changed

+510
-0
lines changed

src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libcmark.pc.in
7070
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcmark.pc
7171
DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
7272

73+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmark-format.in
74+
${CMAKE_CURRENT_BINARY_DIR}/cmark-format)
75+
7376
include (GenerateExportHeader)
7477

7578
add_executable(${PROGRAM} ${PROGRAM_SOURCES})

src/cmark-format.in

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import sys
5+
import argparse
6+
7+
HERE = "@CMAKE_CURRENT_SOURCE_DIR@"
8+
sys.path.append(HERE)
9+
sys.path.append(os.path.join(HERE, os.pardir, 'wrappers'))
10+
11+
from remarkor import *
12+
from wrapper import conf
13+
14+
conf.set_library_path("@CMAKE_CURRENT_BINARY_DIR@")
15+
16+
if __name__=='__main__':
17+
arg_parser = argparse.ArgumentParser()
18+
arg_parser.add_argument('input')
19+
arg_parser.add_argument('--width', type=int, default=80)
20+
args = arg_parser.parse_args()
21+
22+
remarkor = Remarkor.from_filename(args.input)
23+
res = remarkor.remark(width=args.width)
24+
sys.stdout.write(res)

0 commit comments

Comments
 (0)