From cad8471d7650b2634c8ee765f4da3bfab451ac4b Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 27 Dec 2019 07:36:42 -0500 Subject: [PATCH] build man pages using ronn --- CMakeLists.txt | 36 ++++++++++++++++++++++++-- README.md | 1 + doc/man/man3/notcurses.3notcurses | 14 ---------- doc/man/man3/notcurses.3notcurses.ronn | 35 +++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 16 deletions(-) delete mode 100644 doc/man/man3/notcurses.3notcurses create mode 100644 doc/man/man3/notcurses.3notcurses.ronn diff --git a/CMakeLists.txt b/CMakeLists.txt index af5567cfe..8b365ab05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,7 @@ pkg_check_modules(SWSCALE REQUIRED libswscale>=5.0) endif() find_library(LIBRT rt) +# libnotcurses file(GLOB LIBSRCS CONFIGURE_DEPENDS src/lib/*.c) add_library(notcurses SHARED ${LIBSRCS}) set_target_properties(notcurses PROPERTIES @@ -77,6 +78,7 @@ target_compile_definitions(notcurses FORTIFY_SOURCE=2 _GNU_SOURCE SOURCE_DEFAULT ) +# notcurses-demo file(GLOB DEMOSRCS CONFIGURE_DEPENDS src/demo/*.c) add_executable(notcurses-demo ${DEMOSRCS}) target_include_directories(notcurses-demo PRIVATE include) @@ -110,6 +112,30 @@ foreach(f ${POCSRCS}) ) endforeach() +# Documentation +file(GLOB MANSOURCE1 CONFIGURE_DEPENDS doc/man/man1/*.ronn) +file(GLOB MANSOURCE3 CONFIGURE_DEPENDS doc/man/man3/*.ronn) +FIND_PROGRAM(RONN ronn) +iF(NOT RONN) + message(WARNING "ronn not found, won't regenerate man pages") +else() +foreach(m ${MANSOURCE1} ${MANSOURCE3}) + get_filename_component(me "${m}" NAME_WLE) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${m} + DEPENDS ${m} + COMMAND ${RONN} + ARGS -r --pipe ${me}.ronn > ${CMAKE_CURRENT_BINARY_DIR}/${me} + COMMENT "Generating man page with ronn" + ) + add_custom_target(docs + ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${m} + ) + endforeach() +endif() + +# notcurses-input file(GLOB INPUTSRCS CONFIGURE_DEPENDS src/input/*.cpp) add_executable(notcurses-input ${INPUTSRCS}) target_include_directories(notcurses-input @@ -130,6 +156,7 @@ target_compile_definitions(notcurses-input FORTIFY_SOURCE=2 ) +# notcurses-planereel file(GLOB PLANEREELSRCS CONFIGURE_DEPENDS src/planereel/*.cpp) add_executable(notcurses-planereel ${PLANEREELSRCS}) target_include_directories(notcurses-planereel @@ -150,6 +177,7 @@ target_compile_definitions(notcurses-planereel FORTIFY_SOURCE=2 ) +# notcurses-view file(GLOB VIEWSRCS CONFIGURE_DEPENDS src/view/*.cpp) if(NOT "${DISABLE_FFMPEG}") add_executable(notcurses-view ${VIEWSRCS}) @@ -181,6 +209,7 @@ target_compile_definitions(notcurses-view ) endif() +# Testing file(GLOB TESTSRCS CONFIGURE_DEPENDS tests/*.cpp) add_executable(notcurses-tester ${TESTSRCS}) find_package(GTest 1.9 REQUIRED) @@ -205,11 +234,13 @@ target_compile_definitions(notcurses-tester gtest_discover_tests(notcurses-tester) enable_testing() +# pkg-config support configure_file(tools/notcurses.pc.in ${CMAKE_CURRENT_BINARY_DIR}/notcurses.pc @ONLY ) +# CMake support include(CMakePackageConfigHelpers) configure_package_config_file(tools/notcursesConfig.cmake.in @@ -222,6 +253,7 @@ write_basic_package_version_file( COMPATIBILITY SameMajorVersion ) +# Installation install(FILES ${CMAKE_CURRENT_BINARY_DIR}/notcursesConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/notcursesConfigVersion.cmake @@ -239,8 +271,8 @@ install(FILES DESTINATION ${CMAKE_INSTALL_PREFIX}/share/notcurses ) -file(GLOB MANPAGES1 CONFIGURE_DEPENDS doc/man/man1/*) -file(GLOB MANPAGES3 CONFIGURE_DEPENDS doc/man/man3/*) +file(GLOB MANPAGES1 CONFIGURE_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/*.1) +file(GLOB MANPAGES3 CONFIGURE_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/*.3notcurses) install(FILES ${MANPAGES1} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1 diff --git a/README.md b/README.md index c6dc48a52..0a6aa3a33 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ that fine library. * CMake 3.13.0+ * From NCURSES: terminfo 6.1+ * (OPTIONAL) From FFMpeg: libswscale 5.0+, libavformat 57.0+, libavutil 56.0+ +* (man pages) [ronn](https://github.com/rtomayko/ronn) 0.8+ ### Building diff --git a/doc/man/man3/notcurses.3notcurses b/doc/man/man3/notcurses.3notcurses deleted file mode 100644 index 03349f943..000000000 --- a/doc/man/man3/notcurses.3notcurses +++ /dev/null @@ -1,14 +0,0 @@ -.TH notcurses 3notcurses "2019-12-12" - -.SH NAME -notcurses \- TUI library for modern terminal emulators - -.SH SYNOPSIS -.B #include - -.SH DESCRIPTION - -.SH NOTES - -.SH SEE ALSO -notcurses-demo(1) diff --git a/doc/man/man3/notcurses.3notcurses.ronn b/doc/man/man3/notcurses.3notcurses.ronn new file mode 100644 index 000000000..3a6d13ed4 --- /dev/null +++ b/doc/man/man3/notcurses.3notcurses.ronn @@ -0,0 +1,35 @@ +notcurses(3notcurses) -- TUI library for modern terminal emulators +================================================================== + +## SYNOPSIS + +`#include ` + +`-lnotcurses` + +## DESCRIPTION + +notcurses builds atop the terminfo(5) abstraction layer to provide reasonably +portable vivid character displays. It is an intellectual descendant of +ncurses(3NCURSES), but goes beyond that library (and the X/Open Curses API it +implements). notcurses is capable of subregion fades, 24bpp DirectColor, +transparency, multimedia, and safe multithreaded use. + +A program wishing to use notcurses will need to link it, ideally using the +output of `pkg-config --libs notcurses` (see pkg-config(1)). It is advised to +compile with the output of `pkg-config --cflags notcurses`. If using CMake, a +support file is provided, and can be accessed as `notcurses` (see cmake(1)). + +Before calling into notcurses—and usually as one of the first calls of the +program—be sure to call `setlocale(3)` with an appropriate UTF-8 `LC_ALL` +locale. It is usually appropriate to use `setlocale(LC_ALL, "")`, relying on +the user to properly set the `LANG` environment variable. notcurses will +refuse to start if `nl_langinfo(3)` doesn't indicate UTF-8. + +## AUTHORS + +Nick Black + +## SEE ALSO + +notcurses-demo(1), ncurses(3NCURSES), terminfo(5)