From 1ab83e42e24dcc8f6e7f0abb6d76bb5c06a8f189 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 31 Jan 2016 12:48:40 +0200 Subject: Add support for man page generation/install/dist --- buildfile | 2 +- doc/.gitignore | 2 ++ doc/buildfile | 19 +++++++++++ doc/cli.sh | 57 ++++++++++++++++++++++++++++++++ doc/common.css | 1 + doc/man-epilogue.1 | 1 + doc/man-epilogue.xhtml | 1 + doc/man-prologue.1 | 1 + doc/man-prologue.xhtml | 1 + doc/man.css | 1 + doc/pre-box.css | 1 + load/.gitignore | 4 +-- load/buildfile | 8 ++--- load/load.cli | 72 ++++++++++++++++++++++++++++++++++++++++ load/load.cxx | 2 +- load/options.cli | 72 ---------------------------------------- migrate/.gitignore | 4 +-- migrate/buildfile | 8 ++--- migrate/migrate.cli | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++ migrate/migrate.cxx | 2 +- migrate/options.cli | 90 -------------------------------------------------- 21 files changed, 262 insertions(+), 177 deletions(-) create mode 100644 doc/.gitignore create mode 100644 doc/buildfile create mode 100755 doc/cli.sh create mode 120000 doc/common.css create mode 120000 doc/man-epilogue.1 create mode 120000 doc/man-epilogue.xhtml create mode 120000 doc/man-prologue.1 create mode 120000 doc/man-prologue.xhtml create mode 120000 doc/man.css create mode 120000 doc/pre-box.css create mode 100644 load/load.cli delete mode 100644 load/options.cli create mode 100644 migrate/migrate.cli delete mode 100644 migrate/options.cli diff --git a/buildfile b/buildfile index 976b0ed..b070099 100644 --- a/buildfile +++ b/buildfile @@ -2,7 +2,7 @@ # copyright : Copyright (c) 2014-2016 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -d = brep/ etc/ load/ migrate/ tests/ www/ +d = brep/ etc/ load/ migrate/ tests/ www/ doc/ ./: $d doc{INSTALL INSTALL-DEV LICENSE version} file{manifest} include $d diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 0000000..c27d2ca --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1,2 @@ +brep*.xhtml +brep*.1 diff --git a/doc/buildfile b/doc/buildfile new file mode 100644 index 0000000..bd3440f --- /dev/null +++ b/doc/buildfile @@ -0,0 +1,19 @@ +# file : doc/buildfile +# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +cmds = \ +brep-load \ +brep-migrate + +define css: file +css{*}: extension = css + +define xhtml: doc +xhtml{*}: extension = xhtml + +./: {man1 xhtml}{$cmds} \ + css{common pre-box man} \ + file{man-prologue.1 man-epilogue.1 \ + man-prologue.xhtml man-epilogue.xhtml \ + cli.sh} diff --git a/doc/cli.sh b/doc/cli.sh new file mode 100755 index 0000000..11aa660 --- /dev/null +++ b/doc/cli.sh @@ -0,0 +1,57 @@ +#! /usr/bin/env bash + +version="0.2.0" +date="January 2016" + +trap 'exit 1' ERR +set -o errtrace # Trap in functions. + +function info () { echo "$*" 1>&2; } +function error () { info "$*"; exit 1; } + +while [ $# -gt 0 ]; do + case $1 in + --clean) + rm -f brep*.xhtml brep*.1 + exit 0 + ;; + *) + error "unexpected $1" + ;; + esac +done + +function compile () +{ + local n=$1; shift + + # Use a bash array to handle empty arguments. + # + local o=() + while [ $# -gt 0 ]; do + o=("${o[@]}" "$1") + shift + done + + cli -I .. -v project="brep" -v version="$version" -v date="$date" \ +--include-base-last "${o[@]}" --generate-html --html-prologue-file \ +man-prologue.xhtml --html-epilogue-file man-epilogue.xhtml --html-suffix \ +.xhtml ../$n.cli + + cli -I .. -v project="brep" -v version="$version" -v date="$date" \ +--include-base-last "${o[@]}" --generate-man --man-prologue-file \ +man-prologue.1 --man-epilogue-file man-epilogue.1 --man-suffix .1 \ +../$n.cli +} + +o="--output-prefix brep-" + +# A few special cases. +# +#compile "brep" $o --output-prefix "" + +pages="load/load migrate/migrate" + +for p in $pages; do + compile $p $o +done diff --git a/doc/common.css b/doc/common.css new file mode 120000 index 0000000..3ddf6fc --- /dev/null +++ b/doc/common.css @@ -0,0 +1 @@ +style/common.css \ No newline at end of file diff --git a/doc/man-epilogue.1 b/doc/man-epilogue.1 new file mode 120000 index 0000000..878a9ae --- /dev/null +++ b/doc/man-epilogue.1 @@ -0,0 +1 @@ +style/man-epilogue.1 \ No newline at end of file diff --git a/doc/man-epilogue.xhtml b/doc/man-epilogue.xhtml new file mode 120000 index 0000000..6c1722a --- /dev/null +++ b/doc/man-epilogue.xhtml @@ -0,0 +1 @@ +style/man-epilogue.xhtml \ No newline at end of file diff --git a/doc/man-prologue.1 b/doc/man-prologue.1 new file mode 120000 index 0000000..08b5b4b --- /dev/null +++ b/doc/man-prologue.1 @@ -0,0 +1 @@ +style/man-prologue.1 \ No newline at end of file diff --git a/doc/man-prologue.xhtml b/doc/man-prologue.xhtml new file mode 120000 index 0000000..34997e3 --- /dev/null +++ b/doc/man-prologue.xhtml @@ -0,0 +1 @@ +style/man-prologue.xhtml \ No newline at end of file diff --git a/doc/man.css b/doc/man.css new file mode 120000 index 0000000..e0c4308 --- /dev/null +++ b/doc/man.css @@ -0,0 +1 @@ +style/man.css \ No newline at end of file diff --git a/doc/pre-box.css b/doc/pre-box.css new file mode 120000 index 0000000..b9ec76c --- /dev/null +++ b/doc/pre-box.css @@ -0,0 +1 @@ +style/pre-box.css \ No newline at end of file diff --git a/load/.gitignore b/load/.gitignore index 2f464c5..49afbe2 100644 --- a/load/.gitignore +++ b/load/.gitignore @@ -1,3 +1,3 @@ -options -options.?xx +*-options +*-options.?xx brep-load diff --git a/load/buildfile b/load/buildfile index c3a324f..6b72dae 100644 --- a/load/buildfile +++ b/load/buildfile @@ -9,12 +9,12 @@ import libs += libodb%lib{odb} include ../brep/ -exe{brep-load}: \ -{ cxx}{ load } \ -{hxx ixx cxx}{ options } \ +exe{brep-load}: \ +{ cxx}{ load } \ +{hxx ixx cxx}{ load-options } \ ../brep/lib{brep} $libs cli.options += -I $src_root --include-with-brackets --include-prefix load \ --guard-prefix LOAD -{hxx ixx cxx}{options}: cli{options} +{hxx ixx cxx}{load-options}: cli{load} diff --git a/load/load.cli b/load/load.cli new file mode 100644 index 0000000..751d1bd --- /dev/null +++ b/load/load.cli @@ -0,0 +1,72 @@ +// file : load/load.cli +// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +include ; +include ; // uint16_t + +"\section=1" +"\name=brep-load" +"\summary=load build2 repositories into database" + +{ + " ", + + "\h|SYNOPSIS| + + \cb{brep-load --help}\n + \cb{brep-load --version}\n + \c{\b{brep-load} [] } + + \h|DESCRIPTION| + + \cb{brep-load} reads the list of repositories from the specified + configuration , fetches their manifest files, and loads the repository + and package information into the database, suitable for consumption by the + \cb{brep} web module. + + Note that \cb{brep-load} expects the database schema to have already been + created using \l{brep-migrate(1)}." +} + +class options +{ + "\h|OPTIONS|" + + std::string --db-user|-u + { + "", + "Database user name. If not specified, then operating system (login) + name is used." + } + + std::string --db-password + { + "", + "Database password. If not specified, then login without password is + expected to work." + } + + std::string --db-name|-n = "brep" + { + "", + "Database name. If not specified, then '\cb{brep}' is used by default." + } + + std::string --db-host|-h + { + "", + "Database host name, address, or socket. If not specified, then connect + to \cb{localhost} using the operating system-default mechanism + (Unix-domain socket, etc)." + } + + std::uint16_t --db-port|-p = 0 + { + "", + "Database port number. If not specified, the default port is used." + } + + bool --help {"Print usage information and exit."} + bool --version {"Print version and exit."} +}; diff --git a/load/load.cxx b/load/load.cxx index e2a318c..993de7e 100644 --- a/load/load.cxx +++ b/load/load.cxx @@ -28,7 +28,7 @@ #include #include -#include +#include using namespace std; using namespace odb::core; diff --git a/load/options.cli b/load/options.cli deleted file mode 100644 index df91606..0000000 --- a/load/options.cli +++ /dev/null @@ -1,72 +0,0 @@ -// file : load/options.cli -// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -include ; -include ; // uint16_t - -"\section=1" -"\name=brep-load" -"\summary=load repositories into database" - -{ - " ", - - "\h|SYNOPSIS| - - \cb{brep-load --help}\n - \cb{brep-load --version}\n - \c{\b{brep-load} [] } - - \h|DESCRIPTION| - - \cb{brep-load} reads the list of repositories from the specified - configuration , fetches their manifest files, and loads the repository - and package information into the database, suitable for consumption by the - \cb{brep} web module. - - Note that \cb{brep-load} expects the database schema to have already been - created using \l{brep-migrate(1)}." -} - -class options -{ - "\h|OPTIONS|" - - std::string --db-user|-u - { - "", - "Database user name. If not specified, then operating system (login) - name is used." - } - - std::string --db-password - { - "", - "Database password. If not specified, then login without password is - expected to work." - } - - std::string --db-name|-n = "brep" - { - "", - "Database name. If not specified, then '\cb{brep}' is used by default." - } - - std::string --db-host|-h - { - "", - "Database host name, address, or socket. If not specified, then connect - to \cb{localhost} using the operating system-default mechanism - (Unix-domain socket, etc)." - } - - std::uint16_t --db-port|-p = 0 - { - "", - "Database port number. If not specified, the default port is used." - } - - bool --help {"Print usage information and exit."} - bool --version {"Print version and exit."} -}; diff --git a/migrate/.gitignore b/migrate/.gitignore index 580958d..7323078 100644 --- a/migrate/.gitignore +++ b/migrate/.gitignore @@ -1,3 +1,3 @@ -options -options.?xx +*-options +*-options.?xx brep-migrate diff --git a/migrate/buildfile b/migrate/buildfile index c42de5a..cd0b9c8 100644 --- a/migrate/buildfile +++ b/migrate/buildfile @@ -7,12 +7,12 @@ import libs += libodb%lib{odb} include ../brep/ -exe{brep-migrate}: \ -{ cxx}{ migrate } \ -{hxx ixx cxx}{ options } \ +exe{brep-migrate}: \ +{ cxx}{ migrate } \ +{hxx ixx cxx}{ migrate-options } \ ../brep/lib{brep} $libs cli.options += -I $src_root --include-with-brackets --include-prefix migrate \ --guard-prefix MIGRATE -{hxx ixx cxx}{options}: cli{options} +{hxx ixx cxx}{migrate-options}: cli{migrate} diff --git a/migrate/migrate.cli b/migrate/migrate.cli new file mode 100644 index 0000000..35d082f --- /dev/null +++ b/migrate/migrate.cli @@ -0,0 +1,90 @@ +// file : migrate/migrate.cli +// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +include ; +include ; // uint16_t + +"\section=1" +"\name=brep-migrate" +"\summary=create/drop/migrate build2 repository database" + +{ + "", + + "\h|SYNOPSIS| + + \cb{brep-migrate --help}\n + \cb{brep-migrate --version}\n + \c{\b{brep-migrate} []} + + \h|DESCRIPTION| + + In its default mode \cb{brep-migrate} creates the database schema if it + doesn't already exist. Otherwise, it migrates the existing schema and data + to the current version, if needed. + + If the \cb{--recreate} option is specified, then \cb{brep-migrate} instead + recreates the database schema. That is, it drops all the existing tables + (and their data) and then creates them from scratch. + + If the \cb{--drop} option is specified, then \cb{brep-migrate} drops all the + existing tables (and their data). + + The \cb{--recreate} and \cb{--drop} options are mutually exclusive. When + specified, they will cause \cb{brep-migrate} to fail if the database schema + requires migration. In this case you can either migrate the database first + or drop the entire database using, for example, \cb{psql(1)}." +} + +class options +{ + "\h|OPTIONS|" + + bool --recreate + { + "Recreate the database schema (all the existing data will be lost)." + } + + bool --drop + { + "Drop the database schema (all the existing data will be lost)." + } + + std::string --db-user|-u + { + "", + "Database user name. If not specified, then operating system (login) + name is used." + } + + std::string --db-password + { + "", + "Database password. If not specified, then login without password is + expected to work." + } + + std::string --db-name|-n = "brep" + { + "", + "Database name. If not specified, then '\cb{brep}' is used by default." + } + + std::string --db-host|-h + { + "", + "Database host name, address, or socket. If not specified, then connect + to \cb{localhost} using the operating system-default mechanism + (Unix-domain socket, etc)." + } + + std::uint16_t --db-port|-p = 0 + { + "", + "Database port number. If not specified, the default port is used." + } + + bool --help {"Print usage information and exit."} + bool --version {"Print version and exit."} +}; diff --git a/migrate/migrate.cxx b/migrate/migrate.cxx index aa71b67..405770f 100644 --- a/migrate/migrate.cxx +++ b/migrate/migrate.cxx @@ -23,7 +23,7 @@ #include -#include +#include using namespace std; using namespace odb::core; diff --git a/migrate/options.cli b/migrate/options.cli deleted file mode 100644 index e36155c..0000000 --- a/migrate/options.cli +++ /dev/null @@ -1,90 +0,0 @@ -// file : migrate/options.cli -// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -include ; -include ; // uint16_t - -"\section=1" -"\name=brep-migrate" -"\summary=create/drop/migrate brep database" - -{ - "", - - "\h|SYNOPSIS| - - \cb{brep-migrate --help}\n - \cb{brep-migrate --version}\n - \c{\b{brep-migrate} []} - - \h|DESCRIPTION| - - In its default mode \cb{brep-migrate} creates the database schema if it - doesn't already exist. Otherwise, it migrates the existing schema and data - to the current version, if needed. - - If the \cb{--recreate} option is specified, then \cb{brep-migrate} instead - recreates the database schema. That is, it drops all the existing tables - (and their data) and then creates them from scratch. - - If the \cb{--drop} option is specified, then \cb{brep-migrate} drops all the - existing tables (and their data). - - The \cb{--recreate} and \cb{--drop} options are mutually exclusive. When - specified, they will cause \cb{brep-migrate} to fail if the database schema - requires migration. In this case you can either migrate the database first - or drop the entire database using, for example, \cb{psql(1)}." -} - -class options -{ - "\h|OPTIONS|" - - bool --recreate - { - "Recreate the database schema (all the existing data will be lost)." - } - - bool --drop - { - "Drop the database schema (all the existing data will be lost)." - } - - std::string --db-user|-u - { - "", - "Database user name. If not specified, then operating system (login) - name is used." - } - - std::string --db-password - { - "", - "Database password. If not specified, then login without password is - expected to work." - } - - std::string --db-name|-n = "brep" - { - "", - "Database name. If not specified, then '\cb{brep}' is used by default." - } - - std::string --db-host|-h - { - "", - "Database host name, address, or socket. If not specified, then connect - to \cb{localhost} using the operating system-default mechanism - (Unix-domain socket, etc)." - } - - std::uint16_t --db-port|-p = 0 - { - "", - "Database port number. If not specified, the default port is used." - } - - bool --help {"Print usage information and exit."} - bool --version {"Print version and exit."} -}; -- cgit v1.1