Skip to content

Commit 3ff7eff

Browse files
authored
Format and cleanup site/source/docs/api_reference/advanced-apis.rst. NFC (#16523)
- Use hyperlinks in footnotes to make the source easier to read - Reformat at 80 columns - Remove redundant/out-of-date note about "The small number of options that developers may have cause to change" (this is covered above and also not so true anymore since we have settings_internal)
1 parent 026f15a commit 3ff7eff

File tree

2 files changed

+38
-22
lines changed

2 files changed

+38
-22
lines changed

site/source/docs/api_reference/advanced-apis.rst

+32-17
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
Advanced APIs
55
=============
66

7-
This section lists APIs that are not suitable for general use, but which may be useful to developers in some circumstances. These include APIs that are difficult or complicated to use, or which are intended primarily for developers working on the Emscripten core.
7+
This section lists APIs that are not suitable for general use, but which may be
8+
useful to developers in some circumstances. These include APIs that are
9+
difficult or complicated to use, or which are intended primarily for developers
10+
working on the Emscripten core.
811

912
.. contents:: Table of Contents
1013
:local:
@@ -14,42 +17,51 @@ This section lists APIs that are not suitable for general use, but which may be
1417
.. _settings-js:
1518

1619
settings.js
17-
============
18-
19-
`settings.js <https://github.com/emscripten-core/emscripten/blob/main/src/settings.js>`_ contains default values and options used in various places by the compiler.
20+
===========
2021

21-
.. Warning :: Many **settings.js** options are highly brittle - certain combinations of options, and combinations of certain options used with some source code, can cause Emscripten to fail badly. This is intended for use by "advanced users", and possibly even only people developing Emscripten itself.
22+
`settings.js`_ contains default values and options used in various places by the
23+
compiler.
2224

25+
.. Warning:: Many **settings.js** options are highly brittle - certain
26+
combinations of options, and combinations of certain options used with some
27+
source code, can cause Emscripten to fail badly. This is intended for use by
28+
"advanced users", and possibly even only people developing Emscripten itself.
2329

24-
The options in **settings.js** are normally set as command line parameters to *emcc*: ::
30+
The options in **settings.js** are normally set as command line parameters to
31+
*emcc*::
2532

2633
emcc -s OPT=VALUE
2734

28-
29-
While it is possible to edit **settings.js** manually, this is *highly discouraged*. In general **settings.js** defines low-level options that should not be modified. Note also that the compiler changes some options depending on other settings. For example, ``ASSERTIONS`` is enabled by default, but disabled in optimized builds (``-O1+``).
30-
31-
The small number of options that developers may have cause to change should be modified when the *emcc* tool is invoked. For example, ``EXPORTED_FUNCTIONS``: ::
32-
33-
./emcc tests/hello_function.cpp -o function.html -s EXPORTED_FUNCTIONS=_int_sqrt
34-
35+
While it is possible to edit **settings.js** manually, this is *highly
36+
discouraged*. In general **settings.js** defines low-level options that should
37+
not be modified. Note also that the compiler changes some options depending on
38+
other settings. For example, ``ASSERTIONS`` is enabled by default, but disabled
39+
in optimized builds (``-O1+``).
3540

3641
preamble.js
3742
===========
3843

39-
The following advanced APIs are documented in `preamble.js <https://github.com/emscripten-core/emscripten/blob/main/src/preamble.js>`_.
44+
The following advanced APIs are documented in `preamble.js`_.
4045

4146
.. js:function:: allocate(slab, allocator)
4247

43-
This is marked as *internal* because it is difficult to use (it has been optimized for multiple syntaxes to save space in generated code). Normally developers should instead allocate memory using ``_malloc()``, initialize it with :js:func:`setValue`, etc., but this function may be useful for advanced developers in certain cases.
48+
This is marked as *internal* because it is difficult to use (it has been
49+
optimized for multiple syntaxes to save space in generated code). Normally
50+
developers should instead allocate memory using ``_malloc()``, initialize it
51+
with :js:func:`setValue`, etc., but this function may be useful for advanced
52+
developers in certain cases.
4453

45-
:param slab: An array of data, or a number. If a number, then the size of the block to allocate, in *bytes*.
54+
:param slab: An array of data, or a number. If a number, then the size of the
55+
block to allocate, in *bytes*.
4656
:param allocator: How to allocate memory, see ALLOC_*
4757

4858

4959
Advanced File System API
5060
========================
5161

52-
:ref:`Filesystem-API` covers the public API that will be relevant to most developers. The following functions are only needed for advanced use-cases (for example, writing a new local file system) or legacy file system compatibility.
62+
:ref:`Filesystem-API` covers the public API that will be relevant to most
63+
developers. The following functions are only needed for advanced use-cases (for
64+
example, writing a new local file system) or legacy file system compatibility.
5365

5466
.. js:function::
5567
FS.hashName(parentid, name)
@@ -106,3 +118,6 @@ There are also a small number of additional :ref:`flag modes <fs-read-and-write-
106118
- ``xw+``
107119
- ``xa``
108120
- ``xa+``
121+
122+
.. _settings.js: https://github.com/emscripten-core/emscripten/blob/main/src/settings.js
123+
.. _preamble.js: https://github.com/emscripten-core/emscripten/blob/main/src/preamble.js

site/source/docs/api_reference/index.rst

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
API Reference
55
=============
66

7-
This section lists Emscripten's public API, organised by header file. At a very high level it consists of:
7+
This section lists Emscripten's public API, organised by header file. At a very
8+
high level it consists of:
89

910
- :ref:`emscripten-h`:
1011
APIs for integrating with the browser environment.
@@ -25,13 +26,15 @@ This section lists Emscripten's public API, organised by header file. At a very
2526
Enables writing multithreaded programs using a web-like API.
2627

2728
- :ref:`Module`:
28-
Global JavaScript object that can be used to control code execution and access exported methods.
29+
Global JavaScript object that can be used to control code execution and access
30+
exported methods.
2931

3032
- :ref:`val-h`:
3133
Embind API to support transliteration of JavaScript code to C++.
3234

3335
- :ref:`bind-h`:
34-
Embind API for binding C++ functions and classes so that they can be called from JavaScript in a natural way.
36+
Embind API for binding C++ functions and classes so that they can be called
37+
from JavaScript in a natural way.
3538

3639
- :ref:`trace-h`:
3740
A tracing API for doing memory usage analysis.
@@ -58,5 +61,3 @@ This section lists Emscripten's public API, organised by header file. At a very
5861
fiber.h
5962
wasm_workers
6063
advanced-apis
61-
62-

0 commit comments

Comments
 (0)