Skip to content

Commit

Permalink
Include manpages, and make them translatable.
Browse files Browse the repository at this point in the history
Documentation.cmake rules vastly inspired from Julian Andres Klose's amazing
work to migrate Apt to CMake (not included in apt yet).

(bzr r729.4.1)
  • Loading branch information
Mathieu Trudel-Lapierre committed Dec 24, 2010
1 parent af46755 commit 1dfb459
Show file tree
Hide file tree
Showing 11 changed files with 629 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
project (unity)
cmake_minimum_required(VERSION 2.8)

subdirs (libunity services tests tools)
include (cmake/Documentation.cmake)

subdirs (libunity services tests tools doc)

#
# Base bits
Expand Down
111 changes: 111 additions & 0 deletions cmake/Documentation.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Copyright (C) 2009 Julian Andres Klode <[email protected]>.
# Licensed under the same terms as APT; i.e. GPL 2 or later.

macro(add_debiandoc target sourcefiles installdest)
foreach(file ${sourcefiles})
get_filename_component(relfile ${file} NAME)
string(REPLACE ".sgml" "" manual ${relfile})
get_filename_component(absolute ${file} ABSOLUTE)

add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${manual}.html
COMMAND debiandoc2html ${absolute}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${file}
)
set(commands ${commands} ${CMAKE_CURRENT_BINARY_DIR}/${manual}.html)
if (NOT ${installdest} EQUAL "" )
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${manual}.html
DESTINATION ${installdest})
endif (NOT ${installdest} EQUAL "" )
endforeach(file ${sourcefiles})

add_custom_target(${target} ALL DEPENDS ${commands})
endmacro(add_debiandoc target sourcefiles installdest)


macro(add_po4a type master po target deps)
add_custom_command(OUTPUT ${target}
COMMAND po4a-translate --keep 0 -f ${type} -m ${master}
-p ${po} -l ${target}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${deps} ${master} ${po})
endmacro(add_po4a type master po target deps)


# Macro for XML man pages.
macro(add_xml_manpages target manpages translations entities)
foreach(manpage ${manpages})
string(LENGTH ${manpage} manpage_length)
math(EXPR manpage_length ${manpage_length}-1)
string(SUBSTRING ${manpage} ${manpage_length} 1 section)

add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${manpage}
COMMAND xmlto man ${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.xml
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${manpage}.xml
)


set(commands ${commands} ${CMAKE_CURRENT_BINARY_DIR}/${manpage})

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${manpage}
DESTINATION share/man/man${section})

# Add the translations for the manpage.
foreach(translation ${translations})
set(entities)
# transdir = shortcut to the output directory for translations.
set(transdir ${CMAKE_CURRENT_BINARY_DIR}/${translation})

foreach(entity ${entities})
add_custom_command(OUTPUT ${transdir}/${entity}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${transdir}
COMMAND ${CMAKE_COMMAND} -E copy ${entity} ${transdir})
set(ent_cmds ${ent_cmds} ${transdir}/${entity})
endforeach(entity ${entities})



add_po4a(docbook ${manpage}.xml po/${translation}.po
${transdir}/${manpage}.xml "${ent_cmds}")


add_custom_command(OUTPUT ${transdir}/${manpage}
COMMAND xmlto -o ${transdir} man ${transdir}/${manpage}.xml
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${transdir}/${manpage}.xml)

set(nls-cmd ${nls-cmd} ${transdir}/${manpage})
install(FILES ${transdir}/${manpage}
DESTINATION share/man/${translation}/man${section})

endforeach(translation ${translations})
endforeach(manpage ${manpages})

add_custom_target(${target} ALL DEPENDS ${commands})
# Sort the list of the translations.
list(SORT nls-cmd)
add_custom_target(nls-${target} ALL DEPENDS ${nls-cmd})
endmacro(add_xml_manpages manpages)


macro(add_manpages target manpages translations)
foreach(man ${manpages})
string(LENGTH ${man} manpage_length)
math(EXPR manpage_length ${manpage_length}-1)
string(SUBSTRING ${man} ${manpage_length} 1 section)
install(FILES ${man} DESTINATION share/man/man${section})

if (USE_NLS)
foreach(translation ${translations})
set(transdir ${CMAKE_CURRENT_BINARY_DIR}/${translation})
add_po4a(man ${man} po/${translation}.po ${transdir}/${man} "")
install(FILES ${transdir}/${man}
DESTINATION share/man/${translation}/man${section})
set(files ${files} ${transdir}/${man})
endforeach(translation ${translations})
endif(USE_NLS)
endforeach(man ${manpages})
add_custom_target(${target} ALL DEPENDS ${files})
endmacro(add_manpages target manpages translations)
3 changes: 3 additions & 0 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(manpages "unity.1;unity-panel-service.1")

add_manpages(doc-rawman "${manpages}" "fr;")
28 changes: 28 additions & 0 deletions doc/fr/unity-panel-service.fr.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.\"*******************************************************************
.\"
.\" This file was generated with po4a. Translate the source file.
.\"
.\"*******************************************************************
.TH unity\-panel\-service 1 "8 Décembre 2010" "" "Manuel de l'utilisateur Linux"

.SH NOM
unity\-panel\-service \- programme pour l'affichage du paneau dans le shell
Unity.

.SH SYNOPSIS
\fBunity\-panel\-service\fP
.br

.SH DESCRIPTION
Le programme \fBunity\-panel\-service\fP est automatiquement démarré par le
shell Unity (qui est démarré en tant que module Compiz) et est utilisé
pour peindre à l'écran les paneaux qui sont utilisés pour afficher le
menu global, ou alors pour contenir les indicateurs.

.SH OPTIONS
\fBunity\-panel\-service\fP n'attend pas d'options.

.SH NOTES

.SH "VOIR AUSSI"

41 changes: 41 additions & 0 deletions doc/fr/unity.fr.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.\"*******************************************************************
.\"
.\" This file was generated with po4a. Translate the source file.
.\"
.\"*******************************************************************
.TH unity 1 "9 December 2010" "" "Manuel de l'utilisateur Linux"

.SH NOM
unity \- script pour dmarrer et contrler le shell Unity

.SH SYNOPSIS
\fBunity\fP [\fIoptions\fP]
.br

.SH DESCRIPTION
Le programme \fBunity\fP peut tre utilis afin de dmarrer le shell Unity ainsi
que pour configurer les paramtres de log, dboguage, et comment agir avec le
profile utilisateur.

.SH OPTIONS
.IP \fB\-\-advanced\-debug\fP
Dmarre unity avec les options de dboguage (en utilisant GDB ou un autre
outil cet effet) pour aider les dveloppeurs indentifier des problmes dans
le but de complter un rapport de bogue.

.IP \fB\-\-log\fP \<filename\>
Ce paramtre, suivi d'un chemin d'accs ou du nom d'un fichier, prcise o le
shell Unity doit crire les logs.

.IP \fB\-\-reset\fP
Cette option permet l'utilisateur de rinitialiser son profile et remettre
zro les paramtres dans compiz.

.IP \fB\-\-verbose\fP
Cette option active l'affichage d'informations supplmentaires pour le shell
Unity. Elle peut tre utilise par l'utilisateur pour dceler des problmes de
configuration. Cette option est souvent utilise avec \fB\-\-log\fP pour
enregistrer la sortie dans un fichier.

.SH "VOIR AUSSI"
\fBunity\-panel\-service\fP (1)
15 changes: 15 additions & 0 deletions doc/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/make

doc: po4a

clean: po4a-clean

.PHONY: update-po po4a
update-po:
po4a --previous --no-backups --force --no-translations po4a.conf

po4a-clean:
po4a --previous --rm-backups --rm-translations po4a.conf

po4a:
po4a --previous --no-backups po4a.conf
Loading

0 comments on commit 1dfb459

Please sign in to comment.