{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": [
     "remove-input",
     "active-ipynb",
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "try:\n",
    "    from openmdao.utils.notebook_utils import notebook_mode  # noqa: F401\n",
    "except ImportError:\n",
    "    !python -m pip install openmdao[notebooks]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Local Building of OpenMDAO Documentation\n",
    "\n",
    "When developing new features for OpenMDAO, it will be necessary to build the documents locally, to ensure things like code embedding and formatting and links are all working the way the author intends them to work. The documentation uses jupyter notebooks, and building them requires installation of some new packages. You can install these packages by running the OpenMDAO setup script and telling it to install the documentation dependencies like this: \n",
    "\n",
    "```\n",
    "pip install -e .[docs]\n",
    "```\n",
    "\n",
    "\n",
    "## Setup for building the MPI examples (optional)\n",
    "\n",
    "The documentation includes several examples that demonstrate MPI features. In order to build and test their documentation, there are some additional steps.  If you don't have MPI installed, or otherwise don't wish to build the MPI portion of the documentation, you can skip these, but you will see errors from the MPI feature docs in your build output.\n",
    "\n",
    "The following steps only need to be done once on your local system.\n",
    "\n",
    "```\n",
    "jupyter serverextension enable --py ipyparallel;\n",
    "ipython profile create --parallel --profile=mpi;\n",
    "echo \"c.IPClusterEngines.engine_launcher_class = 'MPIEngineSetLauncher'\" >> ~/.ipython/profile_mpi/ipcluster_config.py;\n",
    "echo \"c.IPClusterStart.controller_launcher_class = 'MPIControllerLauncher'\" >> ~/.ipython/profile_mpi/ipcluster_config.py;\n",
    "```\n",
    "\n",
    "Before you build your docs, you will need to launch a server for iPython Parallel:\n",
    "\n",
    "```\n",
    "ipcluster start -n 4 --profile=mpi &\n",
    "```\n",
    "\n",
    "This server only need to run while you build the docs, so you can terminate it afterwards.\n",
    "\n",
    "## Build all docs with build_all_docs.sh\n",
    "\n",
    "The docs are found in the `openmdao/docs` directory in the OpenMDAO repo. The first time you build the docs, run:\n",
    "\n",
    "```\n",
    ". ./build_all_docs.sh\n",
    "```\n",
    "\n",
    "This will clean out any old build and build the docs completely from scratch.\n",
    "\n",
    "## Incremental build\n",
    "\n",
    "Once you have a complete build of the docs and beging editing files, you can do an incremental build which will only rebuild the files that you touched. This can be done by running the following:\n",
    "\n",
    "```\n",
    "python build_jupyter_book.py\n",
    "```\n",
    "\n",
    "Building everything can take a while, so this is useful when making small changes to a feature.\n",
    "\n",
    "When you create your first notebook, be sure to checkout out style guide [here](doc_style_guide.ipynb)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  },
  "orphan": true
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
