|
| 1 | +## Instructions to Build & Run Documentation Locally |
| 2 | +This guide provides instructions for setting up your environment, building, and running the EvalAI documentation on your local machine. |
| 3 | + |
| 4 | +Building and running the documentation locally will help you to ensure accuracy, correct formatting, and preview changes before submitting a pull request. |
| 5 | + |
| 6 | +### Prerequisites & Setup |
| 7 | + |
| 8 | +1. Set up the Project locally |
| 9 | + |
| 10 | + Before building the `docs/` project, make sure you have cloned and set up EvalAI project locally. |
| 11 | + |
| 12 | + To set up the development environment first, follow the [installation instructions](https://github.com/Cloud-CV/EvalAI/blob/master/README.md#installation-instructions) in README. |
| 13 | + |
| 14 | +2. Create a Virtual Environment (Recommended) |
| 15 | + |
| 16 | + EvalAI and its documentation tools require Python 3. We recommend using Python 3.10 or newer. |
| 17 | + Also, it's a best practice to work within a Python virtual environment to avoid conflicts with your system's Python packages. |
| 18 | + |
| 19 | + From the root directory of EvalAI project (where `requirements/` folder is located), create and activate a virtual environment: |
| 20 | + |
| 21 | + |
| 22 | + ``` |
| 23 | + # Create a virtual environment with python 3.10 |
| 24 | + python3.10 -m venv docs-env |
| 25 | +
|
| 26 | + # Activate the virtual environment |
| 27 | + # On macOS/Linux: |
| 28 | + source docs-env/bin/activate |
| 29 | +
|
| 30 | + # On Windows (Command Prompt): |
| 31 | + docs-env\Scripts\activate.bat |
| 32 | + ``` |
| 33 | +
|
| 34 | +### Install Documentation Dependencies |
| 35 | +
|
| 36 | +With your virtual environment activated, install the specific Python packages required to build the documentation. These are listed in `requirements/readthedocs.txt`. |
| 37 | +
|
| 38 | +From the root directory of EvalAI, run the installation command: |
| 39 | +
|
| 40 | +``` |
| 41 | +pip install -r requirements/readthedocs.txt |
| 42 | +``` |
| 43 | +
|
| 44 | +### Build the Documentation |
| 45 | +Once the dependencies are installed, build the HTML documentation. |
| 46 | +
|
| 47 | +Navigate to the docs directory and run the build command: |
| 48 | +
|
| 49 | +``` |
| 50 | +cd docs |
| 51 | +make html |
| 52 | +``` |
| 53 | +
|
| 54 | +### View Documentation Locally |
| 55 | +After a successful build, you can open the generated HTML files in your web browser. |
| 56 | +
|
| 57 | +From the `docs` directory, run the following command: |
| 58 | +``` |
| 59 | +# On macOS: |
| 60 | +open build/html/index.html |
| 61 | + |
| 62 | +# On Windows (Command Prompt): |
| 63 | +start build\html\index.html |
| 64 | + |
| 65 | +# On Linux (using xdg-open for default browser): |
| 66 | +xdg-open build/html/index.html |
| 67 | +``` |
| 68 | +
|
| 69 | +Alternatively, you can always navigate manually: |
| 70 | +
|
| 71 | +Just go to `evalai/docs/build/html/` on your file explorer/finder |
| 72 | +and double-click `index.html`. |
| 73 | +
|
| 74 | +### Live Preview (Recommended) |
| 75 | +For a more efficient development workflow, `sphinx-autobuild` automatically rebuilds the documentation and refreshes your web browser whenever you save changes to your documentation source files. This eliminates the need to manually run `make html` and refresh your browser repeatedly. |
| 76 | +
|
| 77 | +To start the live preview server, run the following command from the root of the project: |
| 78 | +
|
| 79 | +> Note: It's important to run this command from the root directory, NOT inside the `docs` directory. |
| 80 | +
|
| 81 | +``` |
| 82 | +sphinx-autobuild docs/source docs/build/html |
| 83 | +``` |
| 84 | +It will start a local web server, typically at `http://127.0.0.1:8000/`. To stop the live preview server, press `Ctrl+C` in your terminal. |
| 85 | +
|
| 86 | +With this, you're ready to start contributing to the docs! |
| 87 | +
|
| 88 | +## Troubleshooting |
| 89 | +Encountering issues? Don't worry, here are some common problems and their fixes: |
| 90 | +
|
| 91 | +- ### Incompatible Python Version: |
| 92 | + Many package version errors occur mostly due to a wrong or incompatible python version. |
| 93 | +
|
| 94 | + Hence, make sure you're using a dedicated virtual environment with `python >=3.10` (preferable) as mentioned in earlier steps, while contributing to the project. |
| 95 | +
|
| 96 | +- ### Sphnix Version Error: |
| 97 | +
|
| 98 | + ``` |
| 99 | + Sphinx version error: |
| 100 | + The sphinxcontrib.applehelp extension used by this project needs at least Sphinx vX.0; it therefore cannot be built with this version. |
| 101 | + make: *** [html] Error 2 |
| 102 | + ``` |
| 103 | +
|
| 104 | + This usually occurs when you're using the wrong or outdated version of Sphinx. |
| 105 | + |
| 106 | + Make sure you've installed docs dependencies as mentioned in the `requirements/readthedocs.txt`. (See installation steps above). |
| 107 | +
|
| 108 | + If the issue still persists, simply run this command: |
| 109 | +
|
| 110 | + ``` |
| 111 | + pip install --upgrade sphinx |
| 112 | + ``` |
| 113 | +- ### Document not included in toctree: |
| 114 | +
|
| 115 | + Sometimes, you'll see a warning message like this while building the docs: |
| 116 | +
|
| 117 | + ``` |
| 118 | + WARNING: document isn't included in any toctree: <filename.md> |
| 119 | + ``` |
| 120 | +
|
| 121 | + This error usually occurs when Sphinx has found a documentation source file (like a .rst or .md file) that exists, but it hasn't been explicitly listed in any `toctree` directive (e.g., `index.rst`). |
| 122 | +
|
| 123 | + It can happen when you've likely created a new `.rst` or `.md` file, but forgot to add its entry to `index.rst` toctree. |
| 124 | + To fix this, mention the filename in `index.rst` file at a appropriate place and build again. |
| 125 | +
|
| 126 | +- ### Document not displayed in Live Preview: |
| 127 | +
|
| 128 | + Newly created sections within docs might not show in the build view. |
| 129 | +
|
| 130 | + This problem occurs due to the previous mentioned problem of `"Document not included in toctree"` and can be fixed with the same given solution. |
0 commit comments