Skip to content

Commit

Permalink
fully automatic generation of man pages
Browse files Browse the repository at this point in the history
  • Loading branch information
lyokha committed Dec 6, 2023
1 parent 919673e commit e91e3d7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 29 deletions.
11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.20)

SET(name g3kb-switch)
SET(HOMEPAGE_URL https://github.com/lyokha/g3kb-switch)
STRING(TIMESTAMP BUILD_DATE "%d %B %Y")
# get version from git tag in github action
STRING(REGEX MATCH [[[0-9](\.[0-9])*]] VERSION "$ENV{GITHUB_REF_NAME}")
IF(NOT VERSION)
Expand All @@ -26,7 +27,6 @@ FIND_PACKAGE(PkgConfig REQUIRED)
PKG_SEARCH_MODULE(GIO REQUIRED gio-2.0)

CONFIGURE_FILE(config.h.in config.h)
CONFIGURE_FILE(docs/metadata.json.in docs/metadata.json)

SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)

Expand Down Expand Up @@ -126,17 +126,19 @@ ENDIF()
OPTION(G3KBSWITCH_INSTALL_MAN_PAGE "Install man documentation" ON)
IF(G3KBSWITCH_INSTALL_MAN_PAGE)
SET(man_page ${name}.1)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/docs/${man_page}.in
${CMAKE_BINARY_DIR}/docs/${man_page})
FIND_PROGRAM(GZIP gzip)
IF (GZIP)
IF(GZIP)
SET(man_gz ${CMAKE_BINARY_DIR}/${man_page}.gz)
ADD_CUSTOM_TARGET(man-${name} ALL DEPENDS ${man_gz})
ADD_CUSTOM_COMMAND(
OUTPUT ${man_gz}
COMMAND ${GZIP} -9 --no-name --to-stdout "${man_page}" >"${man_gz}"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs)
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/docs)
SET(man_page ${man_gz})
ELSE()
SET(man_page ${CMAKE_SOURCE_DIR}/docs/${man_page})
SET(man_page ${CMAKE_BINARY_DIR}/docs/${man_page})
ENDIF()
INSTALL(FILES ${man_page}
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
Expand All @@ -151,3 +153,4 @@ SET(CPACK_RPM_PACKAGE_URL ${HOMEPAGE_URL})
INCLUDE(CPack)
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
SET(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")

15 changes: 2 additions & 13 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
The man page *g3kb-switch.1* was generated by Pandoc 3.1.9.
The template for the man page *g3kb-switch.1.in* was generated by Pandoc 3.1.9.

```ShellSession
$ pandoc g3kb-switch.1.md -s -t man -M "date=$(LANG=C date +'%d %B %Y')" \
--metadata-file ../build/docs/metadata.json |
sed 's/\[CR\]/[CB]/g' > g3kb-switch.1
$ pandoc g3kb-switch.1.md -s -t man | sed 's/\[CR\]/[CB]/g' > g3kb-switch.1.in
```

The metadata file *../build/docs/metadata.json* was preliminary generated by
running

```ShellSession
$ cmake -Bbuild
```

in the top directory of the project.

6 changes: 3 additions & 3 deletions docs/g3kb-switch.1 → docs/g3kb-switch.1.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" Automatically generated by Pandoc 3.1.9
.\"
.TH "G3KB-SWITCH" "1" "06 December 2023" "g3kb-switch 1.4" "User Manual"
.TH "G3KB-SWITCH" "1" "${BUILD_DATE}" "${PROJECT_NAME} ${PROJECT_VERSION}" "User Manual"
.SH NAME
\f[B]g3kb-switch\f[R] - CLI keyboard layout switcher for Gnome 3 and 4x.
.SH SYNOPSIS
Expand Down Expand Up @@ -46,8 +46,8 @@ Details are documented at \c
.UR https://github.com/lyokha/vim-xkbswitch
.UE \c
\&.
.SH AUTHOR
Written by Alexey Radkov.
.SH AUTHORS
Written by Alexey Radkov and Freed-Wu.
.SH REPORTING BUGS
Report bugs to \c
.UR https://github.com/lyokha/g3kb-switch/issues
Expand Down
12 changes: 10 additions & 2 deletions docs/g3kb-switch.1.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
title: G3KB-SWITCH
section: 1
header: User Manual
footer: ${PROJECT_NAME} ${PROJECT_VERSION}
date: ${BUILD_DATE}
...

# NAME
**g3kb-switch** - CLI keyboard layout switcher for Gnome 3 and 4x.

Expand Down Expand Up @@ -39,8 +47,8 @@ layouts in Vim and Neovim when entering and leaving Insert mode via Vim plugin
*vim-xkbswitch*. Details are documented at
<https://github.com/lyokha/vim-xkbswitch>.

# AUTHOR
Written by Alexey Radkov.
# AUTHORS
Written by Alexey Radkov and Freed-Wu.

# REPORTING BUGS
Report bugs to <https://github.com/lyokha/g3kb-switch/issues>.
Expand Down
7 changes: 0 additions & 7 deletions docs/metadata.json.in

This file was deleted.

0 comments on commit e91e3d7

Please sign in to comment.