{text}
'
+ link = f'{text}'
+ page.formatted_contents = page.formatted_contents.replace(i, link)
+
+ def setup(self) -> None:
+ super().setup()
+
+ if not self._data_file:
+ info('Meson refman extension DISABLED')
+ return
+
+ raw = Path(self._data_file).read_text(encoding='utf-8')
+ self._data = loads(raw)
+
+ # Register formater
+ for ext in self.project.extensions.values():
+ ext = T.cast(Extension, ext)
+ ext.formatter.formatting_page_signal.connect(self._formatting_page_cb)
+ info('Meson refman extension LOADED')
+
+ @staticmethod
+ def get_dependencies() -> T.List[T.Type[Extension]]:
+ return [] # In case this extension has dependencies on other extensions
+
+def get_extension_classes() -> T.List[T.Type[Extension]]:
+ return [RefmanLinksExtension]
diff --git a/docs/genrefman.py b/docs/genrefman.py
new file mode 100755
index 000000000..2510ec590
--- /dev/null
+++ b/docs/genrefman.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+
+# Copyright 2021 The Meson development team
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+# http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Hack to make relative imports to mlog possible
+from pathlib import Path
+import sys
+root = Path(__file__).absolute().parents[1]
+sys.path.insert(0, str(root))
+
+# Now run the actual code
+from refman.main import main
+
+if __name__ == '__main__':
+ raise SystemExit(main())
diff --git a/docs/markdown/Adding-arguments.md b/docs/markdown/Adding-arguments.md
index adbc23e13..2aaa88933 100644
--- a/docs/markdown/Adding-arguments.md
+++ b/docs/markdown/Adding-arguments.md
@@ -22,7 +22,7 @@ This makes Meson add the define to all C compilations. Usually you
would use this setting for flags for global settings. Note that for
setting the C/C++ language standard (the `-std=c99` argument in GCC),
you would probably want to use a default option of the `project()`
-function. For details see the [reference manual](Reference-manual.md).
+function. For details see the [reference manual](RefMan.md).
Global arguments have certain limitations. They all have to be defined
before any build targets are specified. This ensures that the global
diff --git a/docs/markdown/Build-options.md b/docs/markdown/Build-options.md
index 4a0b17800..86f100194 100644
--- a/docs/markdown/Build-options.md
+++ b/docs/markdown/Build-options.md
@@ -76,18 +76,17 @@ This type is available since version 0.44.0
A `feature` option has three states: `enabled`, `disabled` or `auto`.
It is intended to be passed as value for the `required` keyword
argument of most functions. Currently supported in
-[`dependency()`](Reference-manual.md#dependency),
-[`find_library()`](Reference-manual.md#compiler-object),
-[`find_program()`](Reference-manual.md#find_program) and
-[`add_languages()`](Reference-manual.md#add_languages) functions.
+[[dependency]],
+[[compiler.find_library]],
+[[find_program]] and
+[[add_languages]] functions.
- `enabled` is the same as passing `required : true`.
- `auto` is the same as passing `required : false`.
- `disabled` do not look for the dependency and always return 'not-found'.
When getting the value of this type of option using `get_option()`, a
-special [feature option
-object](Reference-manual.md#feature-option-object) is returned instead
+special [[@feature]] object is returned instead
of the string representation of the option's value. This object can be
passed to `required`:
diff --git a/docs/markdown/Builtin-options.md b/docs/markdown/Builtin-options.md
index 0536e77bc..37bf715a8 100644
--- a/docs/markdown/Builtin-options.md
+++ b/docs/markdown/Builtin-options.md
@@ -166,7 +166,7 @@ option:
`-Wl,-bitcode_bundle` while linking. These options are incompatible
with `b_asneeded`, so that option will be silently disabled.
-[Shared modules](Reference-manual.md#shared_module) will not have
+[[shared_module]]s will not have
bitcode embedded because `-Wl,-bitcode_bundle` is incompatible with
both `-bundle` and `-Wl,-undefined,dynamic_lookup` which are necessary
for shared modules to work.
diff --git a/docs/markdown/CMake-module.md b/docs/markdown/CMake-module.md
index b82227d9b..ed43f9dfd 100644
--- a/docs/markdown/CMake-module.md
+++ b/docs/markdown/CMake-module.md
@@ -115,9 +115,8 @@ See [the CMake options object](#cmake-options-object) for a complete
reference of all supported functions.
The CMake configuration options object is very similar to the
-[configuration data
-object](Reference-manual.md#configuration-data-object) object returned
-by [`configuration_data`](Reference-manual.md#configuration_data). It
+[[@cfg_data]] object] object returned
+by [[configuration_data]]. It
is generated by the `subproject_options` function
All configuration options have to be set *before* the subproject is
@@ -138,8 +137,8 @@ and supports the following methods:
- `dependency(target)` returns a dependency object for any CMake target. The
`include_type` kwarg *(new in 0.56.0)* controls the include type of the
returned dependency object similar to the same kwarg in the
- [`dependency()`](Reference-manual.md#dependency) function.
- - `include_directories(target)` returns a Meson `include_directories()`
+ [[dependency]] function.
+ - `include_directories(target)` returns a Meson [[@inc]]
object for the specified target. Using this function is not necessary
if the dependency object is used.
- `target(target)` returns the raw build target.
@@ -160,7 +159,7 @@ following methods are supported:
- `add_cmake_defines({'opt1': val1, ...})` add additional CMake commandline defines
- `set_override_option(opt, val)` set specific [build options](Build-options.md)
for targets. This will effectively add `opt=val` to the `override_options`
- array of the [build target](Reference-manual.md#executable)
+ array of the [[build_target]]
- `set_install(bool)` override wether targets should be installed or not
- `append_compile_args(lang, arg1, ...)` append compile flags for a specific
language to the targets
diff --git a/docs/markdown/External-Project-module.md b/docs/markdown/External-Project-module.md
index 640caaf07..901b0ed10 100644
--- a/docs/markdown/External-Project-module.md
+++ b/docs/markdown/External-Project-module.md
@@ -86,7 +86,7 @@ Keyword arguments:
- `verbose`: If set to `true` the output of sub-commands ran to configure, build
and install the project will be printed onto Meson's stdout.
- `env` : environment variables to set, such as `['NAME1=value1', 'NAME2=value2']`,
- a dictionary, or an [`environment()` object](Reference-manual.md#environment-object).
+ a dictionary, or an [[@env]] object.
Returns an [`ExternalProject`](#ExternalProject_object) object
diff --git a/docs/markdown/External-commands.md b/docs/markdown/External-commands.md
index be9d171b6..772459b26 100644
--- a/docs/markdown/External-commands.md
+++ b/docs/markdown/External-commands.md
@@ -22,8 +22,7 @@ Since 0.52.0, you can pass the command environment as a dictionary:
run_command('command', 'arg1', 'arg2', env: {'FOO': 'bar'})
```
-Since 0.50.0, you can also pass the command
-[`environment`](Reference-manual.md#environment-object) object:
+Since 0.50.0, you can also pass the command [[@env]] object:
```meson
env = environment()
diff --git a/docs/markdown/Generating-sources.md b/docs/markdown/Generating-sources.md
index c09819f60..3cdfbc459 100644
--- a/docs/markdown/Generating-sources.md
+++ b/docs/markdown/Generating-sources.md
@@ -8,8 +8,8 @@ Sometimes source files need to be preprocessed before they are passed
to the actual compiler. As an example you might want build an IDL
compiler and then run some files through that to generate actual
source files. In Meson this is done with
-[`generator()`](Reference-manual.md#generator) or
-[`custom_target()`](Reference-manual.md#custom_target).
+[[generator]] or
+[[custom_target]].
## Using custom_target()
@@ -120,7 +120,7 @@ idep_foo = declare_dependency(
```
See [dependencies](Dependencies.md#declaring-your-own), and
-[reference](Reference-manual.md#declare_dependency) for more
+[[declare_dependency]] for more
information.
## Using generator()
@@ -139,7 +139,7 @@ output will be created in a target-private directory `@BUILD_DIR@`.
If you want to generate files for general purposes such as for
generating headers to be used by several sources, or data that will be
installed, and so on, use a
-[`custom_target()`](Reference-manual.md#custom_target) instead.
+[[custom_target]] instead.
```meson
diff --git a/docs/markdown/Gnome-module.md b/docs/markdown/Gnome-module.md
index 2b90e0ceb..9477b292c 100644
--- a/docs/markdown/Gnome-module.md
+++ b/docs/markdown/Gnome-module.md
@@ -225,9 +225,9 @@ useful when running the application locally for example during tests.
* `build_by_default`: causes, when set to true, to have this target be
built by default, that is, when invoking plain `meson compile`, the default
value is true for all built target types
-* `depend_files`: files ([`string`](Reference-manual.md#string-object),
- [`files()`](Reference-manual.md#files), or
- [`configure_file()`](Reference-manual.md#configure_file)) of
+* `depend_files`: files ([[@str]],
+ [[files]], or
+ [[configure_file]]) of
schema source XML files that should trigger a re-compile if changed.
### gnome.gdbus_codegen()
diff --git a/docs/markdown/Hotdoc-module.md b/docs/markdown/Hotdoc-module.md
index 7d9fc555f..d33dd3e7c 100644
--- a/docs/markdown/Hotdoc-module.md
+++ b/docs/markdown/Hotdoc-module.md
@@ -31,21 +31,17 @@ Generates documentation using [hotdoc] and installs it into `$prefix/share/doc/h
**Keyworded arguments:**
-* `sitemap` (*[string] or [file]*) (**required**): The hotdoc sitemap file
-* `index` (*[string] or [file]*) (**required**): Location of the index file
-* `dependencies`(*[targets]*): Targets on which the documentation generation depends on.
+* `sitemap` ([[@str]] or [[@file]]) (**required**): The hotdoc sitemap file
+* `index` ([[@str]] or [[@file]]) (**required**): Location of the index file
+* `dependencies`([[@build_tgt]]): Targets on which the documentation generation depends on.
* `subprojects`: A list of `HotdocTarget` that are used as subprojects for hotdoc to generate
the documentation.
* ... Any argument of `hotdoc` can be used replacing dashes (`-`) with underscores (`_`).
For a full list of available parameters, just have a look at `hotdoc help`.
-[file]: Reference-manual.md#files
-[string]: Reference-manual.md#string-object
-[targets]: Reference-manual.md#build-target-object
-
**Returns:**
-`HotdocTarget`: A [`custom_target`](Reference-manual.md#custom-target-object) with the
+`HotdocTarget`: A [[custom_target]] with the
following extra methods:
* `config_path`: Path to the generated `hotdoc` configuration file.
diff --git a/docs/markdown/IDE-integration.md b/docs/markdown/IDE-integration.md
index 848b812dc..cf1c5c1df 100644
--- a/docs/markdown/IDE-integration.md
+++ b/docs/markdown/IDE-integration.md
@@ -79,7 +79,7 @@ project.
*(New in 0.56.0)* The `extra_files` key lists all files specified via
the `extra_files` kwarg of a build target. See
-[`executable()`](Reference-manual.md#executable).
+[[executable]].
A target usually generates only one file. However, it is possible for
custom targets to have multiple outputs.
diff --git a/docs/markdown/Keyval-module.md b/docs/markdown/Keyval-module.md
index 96d9c1566..fb3513a77 100644
--- a/docs/markdown/Keyval-module.md
+++ b/docs/markdown/Keyval-module.md
@@ -55,4 +55,4 @@ option](Build-options.md).
* The first (and only) argument is the path to the configuration file to
load (usually ".config").
-**Returns**: a [dictionary object](Reference-manual.md#dictionary-object).
+**Returns**: a [[@dict]] object.
diff --git a/docs/markdown/Python-3-module.md b/docs/markdown/Python-3-module.md
index b89ea3e2f..1631b2a90 100644
--- a/docs/markdown/Python-3-module.md
+++ b/docs/markdown/Python-3-module.md
@@ -10,7 +10,7 @@ This module is deprecated and replaced by the
This is a cross platform way of finding the Python 3 executable, which
may have a different name on different operating systems. Returns an
-[external program](Reference-manual.md#external-program-object)
+[[@external_program]]
object.
*Added 0.38.0*
@@ -24,7 +24,7 @@ from `python` module.
Creates a `shared_module` target that is named according to the naming
conventions of the target platform. All positional and keyword
arguments are the same as for
-[shared_module](Reference-manual.md#shared_module).
+[[shared_module]].
`extension_module` does not add any dependencies to the library so user may
need to add `dependencies : dependency('python3')`, see
diff --git a/docs/markdown/Python-module.md b/docs/markdown/Python-module.md
index 6f4120d3a..5d7b5edbf 100644
--- a/docs/markdown/Python-module.md
+++ b/docs/markdown/Python-module.md
@@ -30,7 +30,7 @@ installation will be the one used to run Meson.
If provided, it can be:
- A simple name, eg `python-2.7`, Meson will look for an external program
- named that way, using [find_program]
+ named that way, using [[find_program]]
- A path, eg `/usr/local/bin/python3.4m`
@@ -49,7 +49,7 @@ Keyword arguments are the following:
[`feature`](Build-options.md#features) option can also be passed to the
`required` keyword argument.
- `disabler`: if `true` and no python installation can be found, return a
- [disabler object](Reference-manual.md#disabler-object) instead of a not-found object.
+ [[@disabler]] object instead of a not-found object.
*Since 0.49.0*
- `modules`: a list of module names that this python installation must have.
*Since 0.51.0*
@@ -58,7 +58,7 @@ Keyword arguments are the following:
## `python_installation` object
-The `python_installation` object is an [external program], with several
+The `python_installation` object is an [[@external_program]], with several
added methods.
### Methods
@@ -80,11 +80,11 @@ provided prior to 0.50.0 due to a bug.
shared_module py_installation.extension_module(module_name, list_of_sources, ...)
```
-Create a `shared_module` target that is named according to the naming
+Create a [[shared_module]] target that is named according to the naming
conventions of the target platform.
All positional and keyword arguments are the same as for
-[shared_module], excluding `name_suffix` and `name_prefix`, and with
+[[shared_module]], excluding `name_suffix` and `name_prefix`, and with
the addition of the following:
- `subdir`: By default, Meson will install the extension module in
@@ -95,9 +95,9 @@ the addition of the following:
`extension_module` does not add any dependencies to the library so
user may need to add `dependencies : py_installation.dependency()`,
-see [][`dependency()`].
+see [[dependency]].
-**Returns**: a [buildtarget object]
+**Returns**: a [[@build_tgt]] object
#### `dependency()`
@@ -106,7 +106,7 @@ python_dependency py_installation.dependency(...)
```
This method accepts no positional arguments, and the same keyword
-arguments as the standard [dependency] function. It also supports the
+arguments as the standard [[dependency]] function. It also supports the
following keyword argument:
- `embed`: *(since 0.53.0)* If true, Meson will try to find a python
@@ -126,7 +126,7 @@ void py_installation.install_sources(list_of_files, ...)
Install actual python sources (`.py`).
All positional and keyword arguments are the same as for
-[install_data], with the addition of the following:
+[[install_data]], with the addition of the following:
- `pure`: On some platforms, architecture independent files are
expected to be placed in a separate directory. However, if the
@@ -149,7 +149,7 @@ string py_installation.get_install_dir(...)
Retrieve the directory [][`install_sources()`] will install to.
It can be useful in cases where `install_sources` cannot be used
-directly, for example when using [configure_file].
+directly, for example when using [[configure_file]].
This function accepts no arguments, its keyword arguments are the same
as [][`install_sources()`].
@@ -236,18 +236,9 @@ with [][`get_variable()`], false otherwise.
## `python_dependency` object
-This [dependency object] subclass will try various methods to obtain
+This [[@dep]] object subclass will try various methods to obtain
the compiler and linker arguments, starting with pkg-config then
potentially using information obtained from python's `sysconfig`
module.
It exposes the same methods as its parent class.
-
-[find_program]: Reference-manual.md#find_program
-[shared_module]: Reference-manual.md#shared_module
-[external program]: Reference-manual.md#external-program-object
-[dependency]: Reference-manual.md#dependency
-[install_data]: Reference-manual.md#install_data
-[configure_file]: Reference-manual.md#configure_file
-[dependency object]: Reference-manual.md#dependency-object
-[buildtarget object]: Reference-manual.md#build-target-object
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md
deleted file mode 100644
index 0139becd0..000000000
--- a/docs/markdown/Reference-manual.md
+++ /dev/null
@@ -1,2996 +0,0 @@
-# Reference manual
-
-## Functions
-
-The following functions are available in build files. Click on each to
-see the description and usage. The objects returned by them are [list
-afterwards](#returned-objects).
-
-### add_global_arguments()
-
-``` meson
- void add_global_arguments(arg1, arg2, ...)
-```
-
-Adds the positional arguments to the compiler command line. This
-function has two keyword arguments:
-
-- `language`: specifies the language(s) that the arguments should be
-applied to. If a list of languages is given, the arguments are added
-to each of the corresponding compiler command lines. Note that there
-is no way to remove an argument set in this way. If you have an
-argument that is only used in a subset of targets, you have to specify
-it in per-target flags.
-
-- `native` *(since 0.48.0)*: a boolean specifying whether the arguments should be
- applied to the native or cross compilation. If `true` the arguments
- will only be used for native compilations. If `false` the arguments
- will only be used in cross compilations. If omitted, the flags are
- added to native compilations if compiling natively and cross
- compilations (only) when cross compiling.
-
-The arguments are used in all compiler invocations with the exception
-of compile tests, because you might need to run a compile test with
-and without the argument in question. For this reason only the
-arguments explicitly specified are used during compile tests.
-
-**Note:** Usually you should use `add_project_arguments` instead,
- because that works even when you project is used as a subproject.
-
-**Note:** You must pass always arguments individually `arg1, arg2,
- ...` rather than as a string `'arg1 arg2', ...`
-
-### add_global_link_arguments()
-
-``` meson
- void add_global_link_arguments(*arg1*, *arg2*, ...)
-```
-
-Like `add_global_arguments` but the arguments are passed to the linker.
-
-### add_languages()
-
-``` meson
- bool add_languages(*langs*)
-```
-
-Add programming languages used by the project. Equivalent to having
-them in the `project` declaration. This function is usually used to
-add languages that are only used under some conditions, like this:
-
-```meson
-project('foobar', 'c')
-if compiling_for_osx
- add_languages('objc')
-endif
-if add_languages('cpp', required : false)
- executable('cpp-app', 'main.cpp')
-endif
-```
-
-Takes the following keyword arguments:
-
-- `required`: defaults to `true`, which means that if any of the languages
-specified is not found, Meson will halt. *(since 0.47.0)* The value of a
-[`feature`](Build-options.md#features) option can also be passed.
-
-- `native` *(since 0.54.0)*: if set to `true`, the language will be used to compile for the build
- machine, if `false`, for the host machine.
-
-Returns `true` if all languages specified were found and `false` otherwise.
-
-If `native` is omitted, the languages may be used for either build or host
-machine, but are never required for the build machine. (i.e. it is equivalent
-to `add_languages(*langs*, native: false, required: *required*) and
-add_languages(*langs*, native: true, required: false)`. This default behaviour
-may change to `native: false` in a future Meson version.
-
-### add_project_arguments()
-
-``` meson
- void add_project_arguments(arg1, arg2, ...)
-```
-
-This function behaves in the same way as `add_global_arguments` except
-that the arguments are only used for the current project, they won't
-be used in any other subproject.
-
-### add_project_link_arguments()
-
-``` meson
- void add_project_link_arguments(*arg1*, *arg2*, ...)
-```
-
-Like `add_project_arguments` but the arguments are passed to the linker.
-
-### add_test_setup()
-
-``` meson
- void add_test_setup(*name*, ...)
-```
-
-Add a custom test setup that can be used to run the tests with a
-custom setup, for example under Valgrind. The keyword arguments are
-the following:
-
-- `env`: environment variables to set, such as `['NAME1=value1',
- 'NAME2=value2']`, or an [`environment()`
- object](#environment-object) which allows more sophisticated
- environment juggling. *(since 0.52.0)* A dictionary is also accepted.
-- `exe_wrapper`: a list containing the wrapper command or script followed by the arguments to it
-- `gdb`: if `true`, the tests are also run under `gdb`
-- `timeout_multiplier`: a number to multiply the test timeout with.
- *Since 0.57* if timeout_multiplier is `<= 0` the test has infinite duration,
- in previous versions of Meson the test would fail with a timeout immediately.
-- `is_default` *(since 0.49.0)*: a bool to set whether this is the default test setup.
- If `true`, the setup will be used whenever `meson test` is run
- without the `--setup` option.
-- `exclude_suites` *(since 0.57.0)*: a list of test suites that should be
- excluded when using this setup. Suites specified in the `--suite` option
- to `meson test` will always run, overriding `add_test_setup` if necessary.
-
-To use the test setup, run `meson test --setup=*name*` inside the
-build dir.
-
-Note that all these options are also available while running the
-`meson test` script for running tests instead of `ninja test` or
-`msbuild RUN_TESTS.vcxproj`, etc depending on the backend.
-
-### alias_target
-
-``` meson
-runtarget alias_target(target_name, dep1, ...)
-```
-
-*(since 0.52.0)*
-
-This function creates a new top-level target. Like all top-level
-targets, this integrates with the selected backend. For instance, with
-you can run it as `meson compile target_name`. This is a dummy target
-that does not execute any command, but ensures that all dependencies
-are built. Dependencies can be any build target (e.g. return value of
-[executable()](#executable), custom_target(), etc)
-
-### assert()
-
-``` meson
- void assert(*condition*, *message*)
-```
-
-Abort with an error message if `condition` evaluates to `false`.
-
-*(since 0.53.0)* `message` argument is optional and defaults to print the condition
-statement instead.
-
-### benchmark()
-
-``` meson
- void benchmark(name, executable, ...)
-```
-
-Creates a benchmark item that will be run when the benchmark target is
-run. The behavior of this function is identical to [`test()`](#test)
-except for:
-
-* benchmark() has no `is_parallel` keyword because benchmarks are not run in parallel
-* benchmark() does not automatically add the `MALLOC_PERTURB_` environment variable
-
-*Note:* Prior to 0.52.0 benchmark would warn that `depends` and
-`priority` were unsupported, this is incorrect.
-
-### both_libraries()
-
-``` meson
- buildtarget = both_libraries(library_name, list_of_sources, ...)
-```
-
-*(since 0.46.0)*
-
-Builds both a static and shared library with the given sources.
-Positional and keyword arguments are otherwise the same as for
-[`library`](#library). Source files will be compiled only once and
-object files will be reused to build both shared and static libraries,
-unless `b_staticpic` user option or `pic` argument are set to false in
-which case sources will be compiled twice.
-
-The returned [buildtarget](#build-target-object) always represents the
-shared library. In addition it supports the following extra methods:
-
-- `get_shared_lib()` returns the shared library build target
-- `get_static_lib()` returns the static library build target
-
-### build_target()
-
-Creates a build target whose type can be set dynamically with the
-`target_type` keyword argument.
-
-`target_type` may be set to one of:
-
-- `executable`
-- `shared_library`
-- `shared_module`
-- `static_library`
-- `both_libraries`
-- `library`
-- `jar`
-
-This declaration:
-
-```meson
-executable(