summaryrefslogtreecommitdiffstats
path: root/bitbake/doc
diff options
context:
space:
mode:
authorAntonin Godard <antonin.godard@bootlin.com>2025-04-18 17:15:27 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-04-24 11:53:00 +0100
commita035cd4718e60c1cd1a7b4c679f9fda177ce1c32 (patch)
treeb0777fa416dd648cf70615f1a1948a48fab745b2 /bitbake/doc
parent1215042fa7a67f538d379cabaa0e1ba25c593b9b (diff)
downloadpoky-a035cd4718e60c1cd1a7b4c679f9fda177ce1c32.tar.gz
bitbake: doc: add a new Library Functions document
Add a new document to the BitBake user manual that automatically documents the library functions from their docstrings. The docstrings can be formatted in reStructuredText. Here logging utilities and the bb.utils module is documented. Some members of the utils module were deliberately excluded as their usage is most likely only internal to BitBake. Fixes [YOCTO #9612] (Bitbake rev: 0a711949acc2696f32a61c591ee3ea37041acb91) Signed-off-by: Antonin Godard <antonin.godard@bootlin.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/doc')
-rw-r--r--bitbake/doc/bitbake-user-manual/bitbake-user-manual-library-functions.rst59
-rw-r--r--bitbake/doc/conf.py7
-rw-r--r--bitbake/doc/index.rst1
3 files changed, 67 insertions, 0 deletions
diff --git a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-library-functions.rst b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-library-functions.rst
new file mode 100644
index 0000000000..09e353945b
--- /dev/null
+++ b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-library-functions.rst
@@ -0,0 +1,59 @@
1.. SPDX-License-Identifier: CC-BY-2.5
2
3=================
4Library Functions
5=================
6
7|
8
9This chapter lists common library functions available under the ``lib/``
10directory in BitBake.
11
12These functions can be used in recipes or configuration files with
13:ref:`inline-Python <bitbake-user-manual/bitbake-user-manual-metadata:Inline
14Python Variable Expansion>` or :ref:`Python
15<bitbake-user-manual/bitbake-user-manual-metadata:BitBake-Style Python
16Functions>` functions.
17
18Logging utilities
19=================
20
21Different logging utilities can be used from Python code in recipes or
22configuration files.
23
24The strings passed below can be formatted with ``str.format()``, for example::
25
26 bb.warn("Houston, we have a %s", "bit of a problem")
27
28Formatted string can also be used directly::
29
30 bb.error("%s, we have a %s" % ("Houston", "big problem"))
31
32Python f-strings may also be used::
33
34 h = "Houston"
35 bb.fatal(f"{h}, we have a critical problem")
36
37.. automodule:: bb
38 :members:
39 debug,
40 error,
41 erroronce,
42 fatal,
43 note,
44 plain,
45 verbnote,
46 warn,
47 warnonce,
48
49``bb.utils``
50============
51
52.. automodule:: bb.utils
53 :members:
54 :exclude-members:
55 LogCatcher,
56 PrCtlError,
57 VersionStringException,
58 better_compile,
59 better_exec,
diff --git a/bitbake/doc/conf.py b/bitbake/doc/conf.py
index fc2ee08111..f61241e28b 100644
--- a/bitbake/doc/conf.py
+++ b/bitbake/doc/conf.py
@@ -17,6 +17,8 @@
17import sys 17import sys
18import datetime 18import datetime
19 19
20from pathlib import Path
21
20current_version = "dev" 22current_version = "dev"
21 23
22# String used in sidebar 24# String used in sidebar
@@ -47,6 +49,7 @@ extlinks = {
47extensions = [ 49extensions = [
48 'sphinx.ext.autosectionlabel', 50 'sphinx.ext.autosectionlabel',
49 'sphinx.ext.extlinks', 51 'sphinx.ext.extlinks',
52 'sphinx.ext.autodoc',
50] 53]
51autosectionlabel_prefix_document = True 54autosectionlabel_prefix_document = True
52 55
@@ -99,3 +102,7 @@ html_last_updated_fmt = '%b %d, %Y'
99 102
100# Remove the trailing 'dot' in section numbers 103# Remove the trailing 'dot' in section numbers
101html_secnumber_suffix = " " 104html_secnumber_suffix = " "
105
106# autoconf needs the modules available to auto-generate documentation from the
107# code
108sys.path.insert(0, str(Path('..', 'lib').resolve()))
diff --git a/bitbake/doc/index.rst b/bitbake/doc/index.rst
index ee1660ac15..546ef36c16 100644
--- a/bitbake/doc/index.rst
+++ b/bitbake/doc/index.rst
@@ -16,6 +16,7 @@ BitBake User Manual
16 bitbake-user-manual/bitbake-user-manual-ref-variables-context 16 bitbake-user-manual/bitbake-user-manual-ref-variables-context
17 bitbake-user-manual/bitbake-user-manual-fetching 17 bitbake-user-manual/bitbake-user-manual-fetching
18 bitbake-user-manual/bitbake-user-manual-ref-variables 18 bitbake-user-manual/bitbake-user-manual-ref-variables
19 bitbake-user-manual/bitbake-user-manual-library-functions
19 bitbake-user-manual/bitbake-user-manual-hello 20 bitbake-user-manual/bitbake-user-manual-hello
20 21
21.. toctree:: 22.. toctree::