From f40cee6c3af4c9cec05adf520fc7077a45060434 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Mon, 24 Apr 2023 12:31:10 +0200 Subject: cmake: Use variables set from find_program --- doc/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 61e5c077..6271bb95 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -108,7 +108,7 @@ foreach(file ${ledger_info_files}) if (MAKEINFO) add_custom_command(OUTPUT ${file_base}.info - COMMAND makeinfo --force --no-split -o ${file_base}.info ${CMAKE_CURRENT_SOURCE_DIR}/${file} + COMMAND ${MAKEINFO} --force --no-split -o ${file_base}.info ${CMAKE_CURRENT_SOURCE_DIR}/${file} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} VERBATIM) list(APPEND ledger_doc_files ${file_base}.info) @@ -116,7 +116,7 @@ foreach(file ${ledger_info_files}) if (BUILD_WEB_DOCS AND MAKEINFO) add_custom_command(OUTPUT ${file_base}.html - COMMAND makeinfo --force --html --no-split -o ${file_base}.html ${CMAKE_CURRENT_SOURCE_DIR}/${file} + COMMAND ${MAKEINFO} --force --html --no-split -o ${file_base}.html ${CMAKE_CURRENT_SOURCE_DIR}/${file} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} VERBATIM) list(APPEND ledger_doc_files ${file_base}.html) @@ -127,7 +127,7 @@ foreach(file ${ledger_info_files}) set(papersize --texinfo=@afourpaper) endif() add_custom_command(OUTPUT ${file_base}.pdf - COMMAND texi2pdf ${papersize} -b -q -o ${file_base}.pdf ${CMAKE_CURRENT_SOURCE_DIR}/${file} + COMMAND ${TEXI2PDF} ${papersize} -b -q -o ${file_base}.pdf ${CMAKE_CURRENT_SOURCE_DIR}/${file} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} VERBATIM) list(APPEND ledger_doc_files ${file_base}.pdf) @@ -143,13 +143,13 @@ if (BUILD_WEB_DOCS) endif() if (MAN2HTML) add_custom_command(OUTPUT ledger.1.html - COMMAND ${BASH} -c "man2html ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 | tail -n+3 > ledger.1.html" + COMMAND ${BASH} -c "${MAN2HTML} ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 | tail -n+3 > ledger.1.html" DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 VERBATIM) list(APPEND ledger_doc_files ledger.1.html) elseif(GROFF) add_custom_command(OUTPUT ledger.1.html - COMMAND ${BASH} -c "groff -mandoc -Thtml ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 > ledger.1.html" + COMMAND ${BASH} -c "${GROFF} -mandoc -Thtml ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 > ledger.1.html" DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 VERBATIM) list(APPEND ledger_doc_files ledger.1.html) -- cgit v1.2.3 From f67e2e64b243171112d1d835d015d72fa9886b42 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Mon, 24 Apr 2023 12:32:44 +0200 Subject: manpage: Fix mdoc warning: Empty input line #1452 --- doc/ledger.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ledger.1 b/doc/ledger.1 index fab5625a..82b03b46 100644 --- a/doc/ledger.1 +++ b/doc/ledger.1 @@ -1449,7 +1449,7 @@ initializations. .Sh SEE ALSO .Xr beancount 1 , .Xr hledger 1 - +.Pp The full documentation for .Nm is maintained as a Texinfo manual. If the -- cgit v1.2.3 From 14b90d8d952b40e0a474223e7f74a1e6505d5450 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Mon, 24 Apr 2023 12:35:11 +0200 Subject: doc: Prefer mandoc over groff to generate ledger.1.html --- doc/CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 6271bb95..9a4a728d 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -89,6 +89,7 @@ if (BUILD_DOCS) find_program(TEXI2PDF texi2pdf) find_program(TEX tex) find_program(MAN2HTML man2html) + find_program(MANDOC mandoc) find_program(GROFF groff) set(ledger_info_files ledger3.texi) @@ -147,9 +148,15 @@ if (BUILD_WEB_DOCS) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 VERBATIM) list(APPEND ledger_doc_files ledger.1.html) - elseif(GROFF) + elseif (MANDOC OR GROFF) + set(_cmd ${MANDOC}) + if (NOT _cmd) + # HTML produced by mandoc is much nicer looking, use groff only as a last resort. + message(WARNING "Using ${GROFF} to generate ledger1.html, as mandoc could not be found.") + set(_cmd ${GROFF}) + endif() add_custom_command(OUTPUT ledger.1.html - COMMAND ${BASH} -c "${GROFF} -mandoc -Thtml ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 > ledger.1.html" + COMMAND ${BASH} -c "${_cmd} -mandoc -Thtml ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 > ledger.1.html" DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 VERBATIM) list(APPEND ledger_doc_files ledger.1.html) -- cgit v1.2.3 From 3414238a1080d492d350ae1f245cc2777b2daf08 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Mon, 24 Apr 2023 12:37:50 +0200 Subject: doc: Generate PDF version of ledger manpage when building web docs --- doc/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 9a4a728d..66b92c21 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -160,6 +160,11 @@ if (BUILD_WEB_DOCS) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 VERBATIM) list(APPEND ledger_doc_files ledger.1.html) + add_custom_command(OUTPUT ledger.1.pdf + COMMAND ${BASH} -c "${_cmd} -mandoc -Tpdf ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 > ledger.1.pdf" + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 + VERBATIM) + list(APPEND ledger_doc_files ledger.1.pdf) else() message(FATAL_ERROR "Could not find man2html or groff. HTML version of man page cannot be built.") endif() -- cgit v1.2.3 From 209f6f4a52c923ce8424a0ffcc57cbf0c1a25aea Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Mon, 24 Apr 2023 12:38:25 +0200 Subject: doc: Generate plain text version of ledger manual when building web docs --- doc/CMakeLists.txt | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 66b92c21..58034f63 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -113,14 +113,18 @@ foreach(file ${ledger_info_files}) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} VERBATIM) list(APPEND ledger_doc_files ${file_base}.info) - endif() - - if (BUILD_WEB_DOCS AND MAKEINFO) - add_custom_command(OUTPUT ${file_base}.html - COMMAND ${MAKEINFO} --force --html --no-split -o ${file_base}.html ${CMAKE_CURRENT_SOURCE_DIR}/${file} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} - VERBATIM) - list(APPEND ledger_doc_files ${file_base}.html) + if (BUILD_WEB_DOCS) + add_custom_command(OUTPUT ${file_base}.html + COMMAND ${MAKEINFO} --force --html --no-split -o ${file_base}.html ${CMAKE_CURRENT_SOURCE_DIR}/${file} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} + VERBATIM) + list(APPEND ledger_doc_files ${file_base}.html) + add_custom_command(OUTPUT ${file_base}.txt + COMMAND ${MAKEINFO} --force --plaintext --no-split -o ${file_base}.txt ${CMAKE_CURRENT_SOURCE_DIR}/${file} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} + VERBATIM) + list(APPEND ledger_doc_files ${file_base}.txt) + endif() endif() if (TEXI2PDF AND TEX) -- cgit v1.2.3 From c38c23dcab5d7e5e389ea5527301017571cfce24 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Tue, 25 Apr 2023 11:41:06 +0200 Subject: doc: Generate Ledger Python module documentation using pydoc when building web docs. --- doc/CMakeLists.txt | 12 +++++++++++- doc/mainpage.txt | 4 ++-- src/CMakeLists.txt | 1 + src/global.h | 2 +- src/ledger.hh.in | 3 ++- src/pyledger.cc | 19 ++++++++++++++++++- 6 files changed, 35 insertions(+), 6 deletions(-) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 58034f63..ef93c293 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -170,7 +170,17 @@ if (BUILD_WEB_DOCS) VERBATIM) list(APPEND ledger_doc_files ledger.1.pdf) else() - message(FATAL_ERROR "Could not find man2html or groff. HTML version of man page cannot be built.") + message(WARNING "Could not find man2html or groff. HTML version of man page will not be built.") + endif() + + if (USE_PYTHON AND Python_EXECUTABLE) + add_custom_command(OUTPUT ledger.html + COMMAND ${CMAKE_COMMAND} -E env + PYTHONPATH=${CMAKE_BINARY_DIR} + ${Python_EXECUTABLE} -m pydoc -w ledger + DEPENDS ${CMAKE_BINARY_DIR}/${_ledger_python_module_name} + VERBATIM) + list(APPEND ledger_doc_files ledger.html) endif() endif(BUILD_WEB_DOCS) diff --git a/doc/mainpage.txt b/doc/mainpage.txt index 95db4d12..7958559d 100644 --- a/doc/mainpage.txt +++ b/doc/mainpage.txt @@ -1,9 +1,9 @@ /** -\mainpage API Documentation +\mainpage C++ API Documentation \section intro_sec Introduction -Documentation of the Ledger API is an ongoing process and you are invited +Documentation of the Ledger C++ API is an ongoing process and you are invited to help out and contribute. In case you find this documentation incorrect, incomplete, unclear, or lacking please [open a pull request](https://git.ledger-cli.org/ledger/pulls). diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d847d71a..f229d70c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -136,6 +136,7 @@ set(LEDGER_INCLUDES value.h views.h xact.h + ${PROJECT_BINARY_DIR}/ledger.hh ${PROJECT_BINARY_DIR}/system.hh) # Windows provides no strptime(), so supply our own. diff --git a/src/global.h b/src/global.h index 4892a471..d989d1b2 100644 --- a/src/global.h +++ b/src/global.h @@ -125,7 +125,7 @@ public: << Ledger_VERSION_PATCH; if (Ledger_VERSION_PRERELEASE != 0) out << Ledger_VERSION_PRERELEASE; - if (Ledger_VERSION_DATE != 0) + if (std::strlen(Ledger_VERSION_DATE) > 0) out << '-' << Ledger_VERSION_DATE; out << _(", the command-line accounting tool"); out << _("\nwith"); diff --git a/src/ledger.hh.in b/src/ledger.hh.in index 54e7797c..3dd5a3a8 100644 --- a/src/ledger.hh.in +++ b/src/ledger.hh.in @@ -43,7 +43,8 @@ #define Ledger_VERSION_MINOR @Ledger_VERSION_MINOR@ #define Ledger_VERSION_PATCH @Ledger_VERSION_PATCH@ #define Ledger_VERSION_PRERELEASE "@Ledger_VERSION_PRERELEASE@" -#define Ledger_VERSION_DATE @Ledger_VERSION_DATE@ +#define Ledger_VERSION_DATE "@Ledger_VERSION_DATE@" +#define Ledger_VERSION "@Ledger_VERSION_MAJOR@.@Ledger_VERSION_MINOR@.@Ledger_VERSION_PATCH@" /** * @name Default values diff --git a/src/pyledger.cc b/src/pyledger.cc index e4a5d262..a716f1a5 100644 --- a/src/pyledger.cc +++ b/src/pyledger.cc @@ -29,7 +29,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include "pyinterp.h" @@ -43,6 +43,23 @@ BOOST_PYTHON_MODULE(ledger) { using namespace ledger; + scope().attr("__author__") = "John Wiegley "; + scope().attr("__version__") = Ledger_VERSION; + scope().attr("__date__") = Ledger_VERSION_DATE; + scope().attr("__doc__") = + "Python API Documentation\n\n" + "Documentation of the Ledger Python API is an ongoing process and you are invited\n" + "to help out and contribute. In case you find this documentation incorrect,\n" + "incomplete, unclear, or lacking please open a pull request at\n" + "https://git.ledger-cli.org/ledger/pulls." + ; + +#if !DEBUG_MODE + docstring_options doc_options; + doc_options.disable_cpp_signatures(); +#endif + + if (! python_session.get()) python_session.reset(new python_interpreter_t); -- cgit v1.2.3