├── .gitignore ├── Makefile ├── adding-module.rst ├── conf.py ├── directories.rst ├── index.rst ├── intro.rst └── make.bat /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | _build/ 14 | develop-eggs/ 15 | dist/ 16 | downloads/ 17 | eggs/ 18 | .eggs/ 19 | lib/ 20 | lib64/ 21 | parts/ 22 | sdist/ 23 | var/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *,cover 47 | .hypothesis/ 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | local_settings.py 56 | 57 | # Flask stuff: 58 | instance/ 59 | .webassets-cache 60 | 61 | # Scrapy stuff: 62 | .scrapy 63 | 64 | # Sphinx documentation 65 | docs/_build/ 66 | 67 | # PyBuilder 68 | target/ 69 | 70 | # IPython Notebook 71 | .ipynb_checkpoints 72 | 73 | # pyenv 74 | .python-version 75 | 76 | # celery beat schedule file 77 | celerybeat-schedule 78 | 79 | # dotenv 80 | .env 81 | 82 | # virtualenv 83 | venv/ 84 | ENV/ 85 | 86 | # Spyder project settings 87 | .spyderproject 88 | 89 | # Rope project settings 90 | .ropeproject 91 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # User-friendly check for sphinx-build 11 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) 12 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) 13 | endif 14 | 15 | # Internal variables. 16 | PAPEROPT_a4 = -D latex_paper_size=a4 17 | PAPEROPT_letter = -D latex_paper_size=letter 18 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 19 | # the i18n builder cannot share the environment and doctrees with the others 20 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 21 | 22 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 23 | 24 | help: 25 | @echo "Please use \`make ' where is one of" 26 | @echo " html to make standalone HTML files" 27 | @echo " dirhtml to make HTML files named index.html in directories" 28 | @echo " singlehtml to make a single large HTML file" 29 | @echo " pickle to make pickle files" 30 | @echo " json to make JSON files" 31 | @echo " htmlhelp to make HTML files and a HTML help project" 32 | @echo " qthelp to make HTML files and a qthelp project" 33 | @echo " devhelp to make HTML files and a Devhelp project" 34 | @echo " epub to make an epub" 35 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 36 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 37 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 38 | @echo " text to make text files" 39 | @echo " man to make manual pages" 40 | @echo " texinfo to make Texinfo files" 41 | @echo " info to make Texinfo files and run them through makeinfo" 42 | @echo " gettext to make PO message catalogs" 43 | @echo " changes to make an overview of all changed/added/deprecated items" 44 | @echo " xml to make Docutils-native XML files" 45 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 46 | @echo " linkcheck to check all external links for integrity" 47 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 48 | 49 | clean: 50 | rm -rf $(BUILDDIR)/* 51 | 52 | html: 53 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 54 | @echo 55 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 56 | 57 | dirhtml: 58 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 59 | @echo 60 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 61 | 62 | singlehtml: 63 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 64 | @echo 65 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 66 | 67 | pickle: 68 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 69 | @echo 70 | @echo "Build finished; now you can process the pickle files." 71 | 72 | json: 73 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 74 | @echo 75 | @echo "Build finished; now you can process the JSON files." 76 | 77 | htmlhelp: 78 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 79 | @echo 80 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 81 | ".hhp project file in $(BUILDDIR)/htmlhelp." 82 | 83 | qthelp: 84 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 85 | @echo 86 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 87 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 88 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/MicroPythonDevelopmentDocumentation.qhcp" 89 | @echo "To view the help file:" 90 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/MicroPythonDevelopmentDocumentation.qhc" 91 | 92 | devhelp: 93 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 94 | @echo 95 | @echo "Build finished." 96 | @echo "To view the help file:" 97 | @echo "# mkdir -p $$HOME/.local/share/devhelp/MicroPythonDevelopmentDocumentation" 98 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/MicroPythonDevelopmentDocumentation" 99 | @echo "# devhelp" 100 | 101 | epub: 102 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 103 | @echo 104 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 105 | 106 | latex: 107 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 108 | @echo 109 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 110 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 111 | "(use \`make latexpdf' here to do that automatically)." 112 | 113 | latexpdf: 114 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 115 | @echo "Running LaTeX files through pdflatex..." 116 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 117 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 118 | 119 | latexpdfja: 120 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 121 | @echo "Running LaTeX files through platex and dvipdfmx..." 122 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 123 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 124 | 125 | text: 126 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 127 | @echo 128 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 129 | 130 | man: 131 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 132 | @echo 133 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 134 | 135 | texinfo: 136 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 137 | @echo 138 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 139 | @echo "Run \`make' in that directory to run these through makeinfo" \ 140 | "(use \`make info' here to do that automatically)." 141 | 142 | info: 143 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 144 | @echo "Running Texinfo files through makeinfo..." 145 | make -C $(BUILDDIR)/texinfo info 146 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 147 | 148 | gettext: 149 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 150 | @echo 151 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 152 | 153 | changes: 154 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 155 | @echo 156 | @echo "The overview file is in $(BUILDDIR)/changes." 157 | 158 | linkcheck: 159 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 160 | @echo 161 | @echo "Link check complete; look for any errors in the above output " \ 162 | "or in $(BUILDDIR)/linkcheck/output.txt." 163 | 164 | doctest: 165 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 166 | @echo "Testing of doctests in the sources finished, look at the " \ 167 | "results in $(BUILDDIR)/doctest/output.txt." 168 | 169 | xml: 170 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 171 | @echo 172 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 173 | 174 | pseudoxml: 175 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 176 | @echo 177 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 178 | -------------------------------------------------------------------------------- /adding-module.rst: -------------------------------------------------------------------------------- 1 | Adding a Module 2 | *************** 3 | 4 | When using MicroPython, you have even bigger chance to need your own library 5 | written in C than in other Python implementations. You might want to use one of 6 | the existing libraries for your platform, get access to some peripherals or 7 | other features of the hardware that is not exposed to Python by default, or 8 | even just do something faster and with smaller memory overhead. To do that, you 9 | will need to extend the existing firmware with your own C code, and this 10 | article is going to show you how to do it, using the ESP8266 port as the 11 | example. 12 | 13 | Note: you can use any naming-scheme you like and do not have to name your 14 | variables or data-type in any specific way. If you plan on extending a 15 | Micropython port and create pull requests, you should however use the same 16 | naming scheme of micropython. See the ESP8266 port for examples. 17 | 18 | Adding Your Own Source File 19 | =========================== 20 | 21 | In order to add your own MicroPython module written in C, you need to create a 22 | new C file and add references to it to several files, so that the file is 23 | picked up during the compilation. 24 | 25 | First of all, you need to add it to the ``Makefile``, to the list of source 26 | files in the ``SRC_C`` variable. Make sure to follow the same format as the 27 | other files in there. The order doesn't matter much. 28 | 29 | .. code-block:: make 30 | 31 | SRC_C = \ 32 | main.c \ 33 | system_stm32.c \ 34 | stm32_it.c \ 35 | ... 36 | mymodule.c 37 | ... 38 | 39 | The second file you will need to add to is ``esp8266.ld``, which is the map of 40 | memory used by the compiler. You have to add it to the list of files to be put 41 | in the ``.irom0.text`` section, so that your code goes into the instruction 42 | read-only memory (iROM). If you fail to do that, the compiler will try to put 43 | it in the instruction random-access memory (iRAM), which is a very scarce 44 | resource, and which can get overflown if you try to put too much there. 45 | 46 | Now just create an empty ``mymodule.c`` file, and run the compilation to see 47 | that it is now included in the firmware. 48 | 49 | 50 | Creating a Python Module 51 | ======================== 52 | 53 | We have our file, but it doesn't actually do anything. It's empty, and there 54 | is no new python module that we could import. Time to change that. 55 | 56 | From the C side, modules in MicroPython are simply structs with a certain 57 | structure. Open the ``mymodule.c`` file and put this code inside: 58 | 59 | 60 | .. code-block:: c 61 | 62 | #include "py/nlr.h" 63 | #include "py/obj.h" 64 | #include "py/runtime.h" 65 | #include "py/binary.h" 66 | #include "py/mpconfig.h" 67 | 68 | STATIC const mp_map_elem_t mymodule_globals_table[] = { 69 | { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_mymodule) }, 70 | }; 71 | 72 | STATIC MP_DEFINE_CONST_DICT ( 73 | mp_module_mymodule_globals, 74 | mymodule_globals_table 75 | ); 76 | 77 | const mp_obj_module_t mp_module_mymodule = { 78 | .base = { &mp_type_module }, 79 | .globals = (mp_obj_dict_t*)&mp_module_mymodule_globals, 80 | }; 81 | 82 | What does this code do? It just defines a python module, using 83 | ``mp_obj_module_t`` type, and then initializes some of its fields, such as the 84 | base type, the name, and the dictionary of globals for that module. In that 85 | dictionary, it defines one variable, ``__name__``, with the name of our module 86 | in it. That's it. 87 | 88 | Now, for this module to actually be available for import, we need to add it to 89 | ``mpconfigport.h`` file to ``MICROPY_PORT_BUILTIN_MODULES``: 90 | 91 | .. code-block:: c 92 | 93 | extern const struct _mp_obj_module_t mp_module_mymodule; 94 | 95 | #define MICROPY_PORT_BUILTIN_MODULES \ 96 | { MP_OBJ_NEW_QSTR(MP_QSTR_umachine), (mp_obj_t)&machine_module }, \ 97 | ... 98 | { MP_OBJ_NEW_QSTR(MP_QSTR_mymodule), (mp_obj_t)&mp_module_mymodule }, \ 99 | 100 | Now you can try compiling the firmware and flashing it to your board. Then you 101 | can run ``import mymodule`` and see it imported. 102 | 103 | 104 | Adding a Function 105 | ================= 106 | 107 | Now let's add a simple function to that module. Edit ``mymodule.c`` again and 108 | add this code right after the includes: 109 | 110 | .. code-block:: c 111 | 112 | #include 113 | 114 | STATIC mp_obj_t mymodule_hello(void) { 115 | printf("Hello world!\n"); 116 | return mp_const_none; 117 | } 118 | STATIC MP_DEFINE_CONST_FUN_OBJ_0(mymodule_hello_obj, mymodule_hello); 119 | 120 | 121 | This creates a function object ``mymodule_hello_obj`` which takes no arguments, 122 | and when called, executes the C function ``mymodule_hello``. Also note, that 123 | our function has to return something (as every Python function returns an 124 | mp_obj_t-struct) -- so we return ``None``. Now we need to 125 | actually add that function object to our module: 126 | 127 | .. code-block:: c 128 | 129 | STATIC const mp_map_elem_t mymodule_globals_table[] = { 130 | { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_mymodule) }, 131 | { MP_OBJ_NEW_QSTR(MP_QSTR_hello), (mp_obj_t)&mymodule_hello_obj }, 132 | }; 133 | 134 | Micropython uses the QSTR-macros to define constant strings. This is used to 135 | identify strings and store only unique ones for preserving memory (as it is 136 | very limited on the PyBoard-Hardware). Your port has a file ``qstrdefsport.h``. 137 | In our case add ``Q(hello)`` to the list (on a new line). This will define the 138 | string ``hello`` for Micropython. Failing to do so will result in a missing 139 | file on compilation. 140 | 141 | Now when you compile and flash the firmware, you will be able to import the 142 | module and call the function inside it. 143 | 144 | Function Arguments 145 | ================== 146 | 147 | The ``MP_DEFINE_CONST_FUN_OBJ_0`` macro that we used to define our function is 148 | a shortcut for defining a function with no arguments. We can also define a 149 | function that takes a single argument with ``MP_DEFINE_CONST_FUN_OBJ_1`` -- the 150 | C function then needs to take an argument of type ``mp_obj_t``: 151 | 152 | .. code-block:: c 153 | 154 | STATIC mp_obj_t mymodule_hello(mp_obj_t what) { 155 | printf("Hello %s!\n", mp_obj_str_get_str(what)); 156 | return mp_const_none; 157 | } 158 | STATIC MP_DEFINE_CONST_FUN_OBJ_1(mymodule_hello_obj, mymodule_hello); 159 | 160 | This function will use the C-function ``printf`` to output a string. The 161 | parameter ``what`` will be turned into a string by the 162 | ``mp_obj_str_get_str``-function (i.e. by Micropython). 163 | 164 | Note that the ``mp_obj_str_get_str`` function will automatically raise the 165 | right exception on the python side if the argument we gave it is not a python 166 | string. This is very convenient. 167 | 168 | It's also possible to define functions with variable number of arguments, or 169 | even with keyword arguments -- you can easily find examples of that in the 170 | modules already included in MicroPython. I will not be covering this in detail. 171 | 172 | 173 | Classes 174 | ======= 175 | 176 | A class is a C-struct with certain fields, quite similar to a module: 177 | 178 | .. code-block:: c 179 | 180 | // creating the table of global members 181 | STATIC const mp_rom_map_elem_t mymodule_hello_locals_dict_table[] = { }; 182 | STATIC MP_DEFINE_CONST_DICT(mymodule_hello_locals_dict, 183 | mymodule_hello_locals_dict_table); 184 | 185 | // create the class-object itself 186 | const mp_obj_type_t mymodule_helloObj_type = { 187 | // "inherit" the type "type" 188 | { &mp_type_type }, 189 | // give it a name 190 | .name = MP_QSTR_helloObj, 191 | // give it a print-function 192 | .print = mymodule_hello_print, 193 | // give it a constructor 194 | .make_new = mymodule_hello_make_new, 195 | // and the global members 196 | .locals_dict = (mp_obj_dict_t*)&mymodule_hello_locals_dict, 197 | }; 198 | 199 | It needs two functions: one for creating the class and allocating all the 200 | memory it needs, and one for printing the objects of that class (similar to 201 | python's ``__repr__``). Let's add them near the top of our file: 202 | 203 | .. code-block:: c 204 | 205 | // this is the actual C-structure for our new object 206 | typedef struct _mymodule_hello_obj_t { 207 | // base represents some basic information, like type 208 | mp_obj_base_t base; 209 | // a member created by us 210 | uint8_t hello_number; 211 | } mymodule_hello_obj_t; 212 | 213 | 214 | We define a C-struct, which holds the class data and one additional field 215 | ``hello_number``. Next we need a function to print the object and a constructor: 216 | 217 | .. code-block:: c 218 | 219 | mp_obj_t mymodule_hello_make_new( const mp_obj_type_t *type, 220 | size_t n_args, 221 | size_t n_kw, 222 | const mp_obj_t *args ) { 223 | // this checks the number of arguments (min 1, max 1); 224 | // on error -> raise python exception 225 | mp_arg_check_num(n_args, n_kw, 1, 1, true); 226 | // create a new object of our C-struct type 227 | mymodule_hello_obj_t *self = m_new_obj(mymodule_hello_obj_t); 228 | // give it a type 229 | self->base.type = &mymodule_helloObj_type; 230 | // set the member number with the first argument of the constructor 231 | self->hello_number = mp_obj_get_int(args[0]); 232 | return MP_OBJ_FROM_PTR(self); 233 | } 234 | 235 | 236 | STATIC void mymodule_hello_print( const mp_print_t *print, 237 | mp_obj_t self_in, 238 | mp_print_kind_t kind ) { 239 | // get a ptr to the C-struct of the object 240 | mymodule_hello_obj_t *self = MP_OBJ_TO_PTR(self_in); 241 | // print the number 242 | printf ("Hello(%u)", self->hello_number); 243 | } 244 | 245 | Now we need to add our object to the module, by adding it into the global 246 | member dictionary of our module: 247 | 248 | .. code-block:: c 249 | 250 | STATIC const mp_map_elem_t mymodule_globals_table[] = { 251 | { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_mymodule) }, 252 | { MP_OBJ_NEW_QSTR(MP_QSTR_hello), (mp_obj_t)&mymodule_hello_obj }, 253 | { MP_OBJ_NEW_QSTR(MP_QSTR_helloObj), (mp_obj_t)&mymodule_helloObj_type }, 254 | }; 255 | 256 | Note that both the function ``mymodule_hello_obj`` added earlier to our module 257 | and the class ``mymodule_hello_obj`` are passed as ``mp_obj_t`` to the 258 | globals table of the module. 259 | 260 | Adding Methods 261 | ============== 262 | 263 | Methods in MicroPython are just functions in the class's locals dict. You add 264 | them the same way as you do to modules, just remember that the first argument 265 | is a pointer to the data struct: 266 | 267 | .. code-block:: c 268 | 269 | STATIC mp_obj_t mymodule_hello_increment(mp_obj_t self_in) { 270 | mymodule_hello_obj_t *self = MP_OBJ_TO_PTR(self_in); 271 | self->hello_number += 1; 272 | return mp_const_none; 273 | } 274 | MP_DEFINE_CONST_FUN_OBJ_1(mymodule_hello_increment_obj, 275 | mymodule_hello_increment); 276 | 277 | 278 | Also, don't forget to add them to the locals dict: 279 | 280 | .. code-block:: c 281 | 282 | STATIC const mp_rom_map_elem_t mymodule_hello_locals_dict_table[] = { 283 | { MP_ROM_QSTR(MP_QSTR_inc), MP_ROM_PTR(&mymodule_hello_increment_obj) }, 284 | } 285 | 286 | Using our module in Micropython 287 | =============================== 288 | 289 | Now we can use the module in Micropython after rebuilding our port. For example 290 | you can write a Python snippet like this: 291 | 292 | .. code-block:: python 293 | 294 | import mymodule; 295 | 296 | mymodule.hello (); 297 | a = mymodule.hellObj ( 12 ); 298 | print (mymodule); 299 | mymodule.inc(); 300 | print (mymodule); 301 | 302 | -------------------------------------------------------------------------------- /conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # MicroPython Development Documentation documentation build configuration file, created by 4 | # sphinx-quickstart on Sat Jul 23 17:02:22 2016. 5 | # 6 | # This file is execfile()d with the current directory set to its 7 | # containing dir. 8 | # 9 | # Note that not all possible configuration values are present in this 10 | # autogenerated file. 11 | # 12 | # All configuration values have a default; values that are commented out 13 | # serve to show the default. 14 | 15 | import sys 16 | import os 17 | 18 | # If extensions (or modules to document with autodoc) are in another directory, 19 | # add these directories to sys.path here. If the directory is relative to the 20 | # documentation root, use os.path.abspath to make it absolute, like shown here. 21 | #sys.path.insert(0, os.path.abspath('.')) 22 | 23 | # -- General configuration ------------------------------------------------ 24 | 25 | # If your documentation needs a minimal Sphinx version, state it here. 26 | #needs_sphinx = '1.0' 27 | 28 | # Add any Sphinx extension module names here, as strings. They can be 29 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 30 | # ones. 31 | extensions = [ 32 | 'sphinx.ext.intersphinx', 33 | 'sphinx.ext.mathjax', 34 | 'sphinx.ext.viewcode', 35 | ] 36 | 37 | # Add any paths that contain templates here, relative to this directory. 38 | templates_path = ['_templates'] 39 | 40 | # The suffix of source filenames. 41 | source_suffix = '.rst' 42 | 43 | # The encoding of source files. 44 | #source_encoding = 'utf-8-sig' 45 | 46 | # The master toctree document. 47 | master_doc = 'index' 48 | 49 | # General information about the project. 50 | project = u'MicroPython Development Documentation' 51 | copyright = u'2016, Radomir Dopieralski' 52 | 53 | # The version info for the project you're documenting, acts as replacement for 54 | # |version| and |release|, also used in various other places throughout the 55 | # built documents. 56 | # 57 | # The short X.Y version. 58 | version = '1.0' 59 | # The full version, including alpha/beta/rc tags. 60 | release = '1.0' 61 | 62 | # The language for content autogenerated by Sphinx. Refer to documentation 63 | # for a list of supported languages. 64 | #language = None 65 | 66 | # There are two options for replacing |today|: either, you set today to some 67 | # non-false value, then it is used: 68 | #today = '' 69 | # Else, today_fmt is used as the format for a strftime call. 70 | #today_fmt = '%B %d, %Y' 71 | 72 | # List of patterns, relative to source directory, that match files and 73 | # directories to ignore when looking for source files. 74 | exclude_patterns = ['_build'] 75 | 76 | # The reST default role (used for this markup: `text`) to use for all 77 | # documents. 78 | #default_role = None 79 | 80 | # If true, '()' will be appended to :func: etc. cross-reference text. 81 | #add_function_parentheses = True 82 | 83 | # If true, the current module name will be prepended to all description 84 | # unit titles (such as .. function::). 85 | #add_module_names = True 86 | 87 | # If true, sectionauthor and moduleauthor directives will be shown in the 88 | # output. They are ignored by default. 89 | #show_authors = False 90 | 91 | # The name of the Pygments (syntax highlighting) style to use. 92 | pygments_style = 'sphinx' 93 | 94 | # A list of ignored prefixes for module index sorting. 95 | #modindex_common_prefix = [] 96 | 97 | # If true, keep warnings as "system message" paragraphs in the built documents. 98 | #keep_warnings = False 99 | 100 | 101 | # -- Options for HTML output ---------------------------------------------- 102 | 103 | # The theme to use for HTML and HTML Help pages. See the documentation for 104 | # a list of builtin themes. 105 | html_theme = 'default' 106 | 107 | # Theme options are theme-specific and customize the look and feel of a theme 108 | # further. For a list of options available for each theme, see the 109 | # documentation. 110 | #html_theme_options = {} 111 | 112 | # Add any paths that contain custom themes here, relative to this directory. 113 | #html_theme_path = [] 114 | 115 | # The name for this set of Sphinx documents. If None, it defaults to 116 | # " v documentation". 117 | #html_title = None 118 | 119 | # A shorter title for the navigation bar. Default is the same as html_title. 120 | #html_short_title = None 121 | 122 | # The name of an image file (relative to this directory) to place at the top 123 | # of the sidebar. 124 | #html_logo = None 125 | 126 | # The name of an image file (within the static path) to use as favicon of the 127 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 128 | # pixels large. 129 | #html_favicon = None 130 | 131 | # Add any paths that contain custom static files (such as style sheets) here, 132 | # relative to this directory. They are copied after the builtin static files, 133 | # so a file named "default.css" will overwrite the builtin "default.css". 134 | html_static_path = ['_static'] 135 | 136 | # Add any extra paths that contain custom files (such as robots.txt or 137 | # .htaccess) here, relative to this directory. These files are copied 138 | # directly to the root of the documentation. 139 | #html_extra_path = [] 140 | 141 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 142 | # using the given strftime format. 143 | #html_last_updated_fmt = '%b %d, %Y' 144 | 145 | # If true, SmartyPants will be used to convert quotes and dashes to 146 | # typographically correct entities. 147 | #html_use_smartypants = True 148 | 149 | # Custom sidebar templates, maps document names to template names. 150 | #html_sidebars = {} 151 | 152 | # Additional templates that should be rendered to pages, maps page names to 153 | # template names. 154 | #html_additional_pages = {} 155 | 156 | # If false, no module index is generated. 157 | #html_domain_indices = True 158 | 159 | # If false, no index is generated. 160 | #html_use_index = True 161 | 162 | # If true, the index is split into individual pages for each letter. 163 | #html_split_index = False 164 | 165 | # If true, links to the reST sources are added to the pages. 166 | #html_show_sourcelink = True 167 | 168 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 169 | #html_show_sphinx = True 170 | 171 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 172 | #html_show_copyright = True 173 | 174 | # If true, an OpenSearch description file will be output, and all pages will 175 | # contain a tag referring to it. The value of this option must be the 176 | # base URL from which the finished HTML is served. 177 | #html_use_opensearch = '' 178 | 179 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 180 | #html_file_suffix = None 181 | 182 | # Output file base name for HTML help builder. 183 | htmlhelp_basename = 'MicroPythonDevelopmentDocumentationdoc' 184 | 185 | 186 | # -- Options for LaTeX output --------------------------------------------- 187 | 188 | latex_elements = { 189 | # The paper size ('letterpaper' or 'a4paper'). 190 | #'papersize': 'letterpaper', 191 | 192 | # The font size ('10pt', '11pt' or '12pt'). 193 | #'pointsize': '10pt', 194 | 195 | # Additional stuff for the LaTeX preamble. 196 | #'preamble': '', 197 | } 198 | 199 | # Grouping the document tree into LaTeX files. List of tuples 200 | # (source start file, target name, title, 201 | # author, documentclass [howto, manual, or own class]). 202 | latex_documents = [ 203 | ('index', 'MicroPythonDevelopmentDocumentation.tex', u'MicroPython Development Documentation Documentation', 204 | u'Radomir Dopieralski', 'manual'), 205 | ] 206 | 207 | # The name of an image file (relative to this directory) to place at the top of 208 | # the title page. 209 | #latex_logo = None 210 | 211 | # For "manual" documents, if this is true, then toplevel headings are parts, 212 | # not chapters. 213 | #latex_use_parts = False 214 | 215 | # If true, show page references after internal links. 216 | #latex_show_pagerefs = False 217 | 218 | # If true, show URL addresses after external links. 219 | #latex_show_urls = False 220 | 221 | # Documents to append as an appendix to all manuals. 222 | #latex_appendices = [] 223 | 224 | # If false, no module index is generated. 225 | #latex_domain_indices = True 226 | 227 | 228 | # -- Options for manual page output --------------------------------------- 229 | 230 | # One entry per manual page. List of tuples 231 | # (source start file, name, description, authors, manual section). 232 | man_pages = [ 233 | ('index', 'micropythondevelopmentdocumentation', u'MicroPython Development Documentation Documentation', 234 | [u'Radomir Dopieralski'], 1) 235 | ] 236 | 237 | # If true, show URL addresses after external links. 238 | #man_show_urls = False 239 | 240 | 241 | # -- Options for Texinfo output ------------------------------------------- 242 | 243 | # Grouping the document tree into Texinfo files. List of tuples 244 | # (source start file, target name, title, author, 245 | # dir menu entry, description, category) 246 | texinfo_documents = [ 247 | ('index', 'MicroPythonDevelopmentDocumentation', u'MicroPython Development Documentation Documentation', 248 | u'Radomir Dopieralski', 'MicroPythonDevelopmentDocumentation', 'One line description of project.', 249 | 'Miscellaneous'), 250 | ] 251 | 252 | # Documents to append as an appendix to all manuals. 253 | #texinfo_appendices = [] 254 | 255 | # If false, no module index is generated. 256 | #texinfo_domain_indices = True 257 | 258 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 259 | #texinfo_show_urls = 'footnote' 260 | 261 | # If true, do not generate a @detailmenu in the "Top" node's menu. 262 | #texinfo_no_detailmenu = False 263 | 264 | 265 | # -- Options for Epub output ---------------------------------------------- 266 | 267 | # Bibliographic Dublin Core info. 268 | epub_title = u'MicroPython Development Documentation' 269 | epub_author = u'Radomir Dopieralski' 270 | epub_publisher = u'Radomir Dopieralski' 271 | epub_copyright = u'2016, Radomir Dopieralski' 272 | 273 | # The basename for the epub file. It defaults to the project name. 274 | #epub_basename = u'MicroPython Development Documentation' 275 | 276 | # The HTML theme for the epub output. Since the default themes are not optimized 277 | # for small screen space, using the same theme for HTML and epub output is 278 | # usually not wise. This defaults to 'epub', a theme designed to save visual 279 | # space. 280 | #epub_theme = 'epub' 281 | 282 | # The language of the text. It defaults to the language option 283 | # or en if the language is not set. 284 | #epub_language = '' 285 | 286 | # The scheme of the identifier. Typical schemes are ISBN or URL. 287 | #epub_scheme = '' 288 | 289 | # The unique identifier of the text. This can be a ISBN number 290 | # or the project homepage. 291 | #epub_identifier = '' 292 | 293 | # A unique identification for the text. 294 | #epub_uid = '' 295 | 296 | # A tuple containing the cover image and cover page html template filenames. 297 | #epub_cover = () 298 | 299 | # A sequence of (type, uri, title) tuples for the guide element of content.opf. 300 | #epub_guide = () 301 | 302 | # HTML files that should be inserted before the pages created by sphinx. 303 | # The format is a list of tuples containing the path and title. 304 | #epub_pre_files = [] 305 | 306 | # HTML files shat should be inserted after the pages created by sphinx. 307 | # The format is a list of tuples containing the path and title. 308 | #epub_post_files = [] 309 | 310 | # A list of files that should not be packed into the epub file. 311 | epub_exclude_files = ['search.html'] 312 | 313 | # The depth of the table of contents in toc.ncx. 314 | #epub_tocdepth = 3 315 | 316 | # Allow duplicate toc entries. 317 | #epub_tocdup = True 318 | 319 | # Choose between 'default' and 'includehidden'. 320 | #epub_tocscope = 'default' 321 | 322 | # Fix unsupported image types using the PIL. 323 | #epub_fix_images = False 324 | 325 | # Scale large images. 326 | #epub_max_image_width = 0 327 | 328 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 329 | #epub_show_urls = 'inline' 330 | 331 | # If false, no index is generated. 332 | #epub_use_index = True 333 | 334 | 335 | # Example configuration for intersphinx: refer to the Python standard library. 336 | intersphinx_mapping = {'http://docs.python.org/': None} 337 | -------------------------------------------------------------------------------- /directories.rst: -------------------------------------------------------------------------------- 1 | Directory Structure 2 | ******************* 3 | 4 | The MicroPython repository is divided into a number of directories, each with 5 | its own function. Some of them include: 6 | 7 | 8 | Docs, Logo and Examples 9 | ======================= 10 | 11 | The user documentation for all ports lives in the ``docs`` directory, with some 12 | example code in the ``examples`` directory. The ``logo`` directory contains the 13 | MicroPython logo in various formats. 14 | 15 | 16 | Tests 17 | ===== 18 | 19 | All tests live in the ``tests`` directory. 20 | 21 | 22 | Python Code 23 | =========== 24 | 25 | The ``py`` directory contains the bulk of code for the compiler, runtime 26 | environment and core library of MicroPython. This is where we will be looking 27 | for API functions and macros. 28 | 29 | 30 | Port-specific Code 31 | ================== 32 | 33 | The directories such as ``esp8266``, ``cc3200``, ``pic16bit``, ``teensy``, 34 | ``stmhal``, ``bare-arm``, ``qemu-arm``, ``unix`` and ``windows`` contain code 35 | and tools specific to particular ports of MicroPython. If you are working on a 36 | feature to be added for a specific hardware, this is probably the best place to 37 | put your files. 38 | 39 | 40 | Minimal Port 41 | ============ 42 | 43 | The ``minimal`` directory contains the minimum of files that a new port needs. 44 | You can use this as a template for starting new ports of MicroPython. 45 | 46 | 47 | Common Parts 48 | ============ 49 | 50 | The ``extmod`` directory contains source of MicroPython modules that may are 51 | not part of the core library, but are useful for multiple ports. The 52 | ``drivers`` directory has code for libraries that communicate with various 53 | additional hardware, such as displays or sensors. 54 | 55 | 56 | Tools and Utilities 57 | =================== 58 | 59 | The ``tools`` directory contains various tools useful for working with 60 | MicroPython. The ``mpy-cross`` directory has code for the MicroPython 61 | cross-compiler, which can be used to generate frozen bytecode modules. 62 | -------------------------------------------------------------------------------- /index.rst: -------------------------------------------------------------------------------- 1 | Welcome to MicroPython Development Documentation 2 | ************************************************ 3 | 4 | Contents: 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | intro.rst 10 | directories.rst 11 | adding-module.rst 12 | 13 | 14 | Indices and tables 15 | ================== 16 | 17 | * :ref:`genindex` 18 | * :ref:`modindex` 19 | * :ref:`search` 20 | 21 | -------------------------------------------------------------------------------- /intro.rst: -------------------------------------------------------------------------------- 1 | Introduction 2 | ************ 3 | 4 | This is an unofficial MicroPython development guide. It was written to make it 5 | easier for new developers to start contributing code to the MicroPython 6 | project. It's not comprehensive, and at times might even be wrong, but it is 7 | some starting point. 8 | -------------------------------------------------------------------------------- /make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. xml to make Docutils-native XML files 37 | echo. pseudoxml to make pseudoxml-XML files for display purposes 38 | echo. linkcheck to check all external links for integrity 39 | echo. doctest to run all doctests embedded in the documentation if enabled 40 | goto end 41 | ) 42 | 43 | if "%1" == "clean" ( 44 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 45 | del /q /s %BUILDDIR%\* 46 | goto end 47 | ) 48 | 49 | 50 | %SPHINXBUILD% 2> nul 51 | if errorlevel 9009 ( 52 | echo. 53 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 54 | echo.installed, then set the SPHINXBUILD environment variable to point 55 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 56 | echo.may add the Sphinx directory to PATH. 57 | echo. 58 | echo.If you don't have Sphinx installed, grab it from 59 | echo.http://sphinx-doc.org/ 60 | exit /b 1 61 | ) 62 | 63 | if "%1" == "html" ( 64 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 68 | goto end 69 | ) 70 | 71 | if "%1" == "dirhtml" ( 72 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 76 | goto end 77 | ) 78 | 79 | if "%1" == "singlehtml" ( 80 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 84 | goto end 85 | ) 86 | 87 | if "%1" == "pickle" ( 88 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can process the pickle files. 92 | goto end 93 | ) 94 | 95 | if "%1" == "json" ( 96 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 97 | if errorlevel 1 exit /b 1 98 | echo. 99 | echo.Build finished; now you can process the JSON files. 100 | goto end 101 | ) 102 | 103 | if "%1" == "htmlhelp" ( 104 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 105 | if errorlevel 1 exit /b 1 106 | echo. 107 | echo.Build finished; now you can run HTML Help Workshop with the ^ 108 | .hhp project file in %BUILDDIR%/htmlhelp. 109 | goto end 110 | ) 111 | 112 | if "%1" == "qthelp" ( 113 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 114 | if errorlevel 1 exit /b 1 115 | echo. 116 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 117 | .qhcp project file in %BUILDDIR%/qthelp, like this: 118 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\MicroPythonDevelopmentDocumentation.qhcp 119 | echo.To view the help file: 120 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\MicroPythonDevelopmentDocumentation.ghc 121 | goto end 122 | ) 123 | 124 | if "%1" == "devhelp" ( 125 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished. 129 | goto end 130 | ) 131 | 132 | if "%1" == "epub" ( 133 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 137 | goto end 138 | ) 139 | 140 | if "%1" == "latex" ( 141 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 145 | goto end 146 | ) 147 | 148 | if "%1" == "latexpdf" ( 149 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 150 | cd %BUILDDIR%/latex 151 | make all-pdf 152 | cd %BUILDDIR%/.. 153 | echo. 154 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 155 | goto end 156 | ) 157 | 158 | if "%1" == "latexpdfja" ( 159 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 160 | cd %BUILDDIR%/latex 161 | make all-pdf-ja 162 | cd %BUILDDIR%/.. 163 | echo. 164 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 165 | goto end 166 | ) 167 | 168 | if "%1" == "text" ( 169 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 170 | if errorlevel 1 exit /b 1 171 | echo. 172 | echo.Build finished. The text files are in %BUILDDIR%/text. 173 | goto end 174 | ) 175 | 176 | if "%1" == "man" ( 177 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 178 | if errorlevel 1 exit /b 1 179 | echo. 180 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 181 | goto end 182 | ) 183 | 184 | if "%1" == "texinfo" ( 185 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 186 | if errorlevel 1 exit /b 1 187 | echo. 188 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 189 | goto end 190 | ) 191 | 192 | if "%1" == "gettext" ( 193 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 194 | if errorlevel 1 exit /b 1 195 | echo. 196 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 197 | goto end 198 | ) 199 | 200 | if "%1" == "changes" ( 201 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 202 | if errorlevel 1 exit /b 1 203 | echo. 204 | echo.The overview file is in %BUILDDIR%/changes. 205 | goto end 206 | ) 207 | 208 | if "%1" == "linkcheck" ( 209 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 210 | if errorlevel 1 exit /b 1 211 | echo. 212 | echo.Link check complete; look for any errors in the above output ^ 213 | or in %BUILDDIR%/linkcheck/output.txt. 214 | goto end 215 | ) 216 | 217 | if "%1" == "doctest" ( 218 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 219 | if errorlevel 1 exit /b 1 220 | echo. 221 | echo.Testing of doctests in the sources finished, look at the ^ 222 | results in %BUILDDIR%/doctest/output.txt. 223 | goto end 224 | ) 225 | 226 | if "%1" == "xml" ( 227 | %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml 228 | if errorlevel 1 exit /b 1 229 | echo. 230 | echo.Build finished. The XML files are in %BUILDDIR%/xml. 231 | goto end 232 | ) 233 | 234 | if "%1" == "pseudoxml" ( 235 | %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml 236 | if errorlevel 1 exit /b 1 237 | echo. 238 | echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. 239 | goto end 240 | ) 241 | 242 | :end 243 | --------------------------------------------------------------------------------