summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Hildebrandt <afh@surryhill.net>2023-04-25 11:41:06 +0200
committerAlexis Hildebrandt <afh@surryhill.net>2023-04-25 21:25:54 +0200
commitc38c23dcab5d7e5e389ea5527301017571cfce24 (patch)
tree0f2447c0be2c231dddf40dd92be4ed07566f5ce6
parent209f6f4a52c923ce8424a0ffcc57cbf0c1a25aea (diff)
downloadfork-ledger-c38c23dcab5d7e5e389ea5527301017571cfce24.tar.gz
fork-ledger-c38c23dcab5d7e5e389ea5527301017571cfce24.tar.bz2
fork-ledger-c38c23dcab5d7e5e389ea5527301017571cfce24.zip
doc: Generate Ledger Python module documentation
using pydoc when building web docs.
-rw-r--r--doc/CMakeLists.txt12
-rw-r--r--doc/mainpage.txt4
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/global.h2
-rw-r--r--src/ledger.hh.in3
-rw-r--r--src/pyledger.cc19
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 <system.hh>
+#include <ledger.hh>
#include "pyinterp.h"
@@ -43,6 +43,23 @@ BOOST_PYTHON_MODULE(ledger)
{
using namespace ledger;
+ scope().attr("__author__") = "John Wiegley <jwiegley@gmail.com>";
+ 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);