Skip to content

Commit ced74a9

Browse files
authored
Edit Docusaurus README.mds (mlflow#14325)
Signed-off-by: Daniel Lok <[email protected]>
1 parent a509e5e commit ced74a9

File tree

4 files changed

+121
-113
lines changed

4 files changed

+121
-113
lines changed

CONTRIBUTING.md

+9-73
Original file line numberDiff line numberDiff line change
@@ -831,87 +831,23 @@ We use [taplo](https://taplo.tamasfe.dev/) to enforce consistent TOML formatting
831831

832832
### Writing Docs
833833

834-
First, install dependencies for building docs as described in [Environment Setup and Python configuration](#environment-setup-and-python-configuration).
834+
There are two separate build systems for the MLflow documentation:
835835

836-
Building documentation requires [Pandoc](https://pandoc.org/index.html). It should have already been
837-
installed if you used the automated env setup script
838-
([dev-env-setup.sh](https://github.com/mlflow/mlflow/blob/master/dev/dev-env-setup.sh)),
839-
but if you are manually installing dependencies, please follow [the official instruction](https://pandoc.org/installing.html).
836+
#### API Docs
840837

841-
Also, check the version of your installation via `pandoc --version` and ensure it is 2.2.1 or above.
842-
If you are using Mac OSX, be aware that the Homebrew installation of Pandoc may be outdated. If you are using Linux,
843-
you should use a deb installer or install from the source, instead of running `apt` / `apt-get` commands. Pandoc package available on official
844-
repositories is an older version and contains several bugs. You can find newer versions at <https://github.com/jgm/pandoc/releases>.
838+
The [API reference](https://mlflow.org/docs/latest/api_reference/) is managed by [Sphinx](https://www.sphinx-doc.org/en/master/). The content is primarily populated by our Python docstrings, which are written in reStructuredText (RST).
845839

846-
To generate a live preview of Python & other rst documentation, run the
847-
following snippet. Note that R & Java API docs must be regenerated
848-
separately after each change and are not live-updated; see subsequent
849-
sections for instructions on generating R and Java docs.
840+
For instructions on how to build the API docs, please check the [README.md](https://github.com/mlflow/mlflow/blob/master/docs/api_reference/README.md) in the `docs/api_reference/` subfolder.
850841

851-
```bash
852-
cd docs
853-
make livehtml
854-
```
855-
856-
Generate R API rst doc files via:
857-
858-
```bash
859-
cd docs
860-
make rdocs
861-
```
862-
863-
---
842+
#### Main Docs
864843

865-
**NOTE**
844+
The main MLflow docs (e.g. feature docs, tutorials, etc) are written using [Docusaurus](https://docusaurus.io/). The only prerequisite for building these docs is NodeJS >= 18.0. Please check out the [official NodeJS docs](https://nodejs.org/en/download) for platform-specific installation instructions.
866845

867-
If you attempt to build the R documentation on an ARM-based platform (Apple silicon M1, M2, etc.)
868-
you will likely get an error when trying to execute the Docker build process for the make command.
869-
To address this, set the default docker platform environment variable as follows:
846+
To get started, simply run `yarn && yarn start` from the [`docs/`](https://github.com/mlflow/mlflow/blob/master/docs/) folder. This will spin up a development server that can be viewed at `http://localhost:3000/` (by default). The source files (primarily `.MDX`) are located in the [`docs/docs/`](https://github.com/mlflow/mlflow/blob/master/docs/docs/) subfolder. Changes to these files should be automatically reflected in the development server!
870847

871-
```bash
872-
export DOCKER_DEFAULT_PLATFORM=linux/amd64
873-
```
874-
875-
---
876-
877-
Generate Java API rst doc files via:
878-
879-
```bash
880-
cd docs
881-
make javadocs
882-
```
848+
There are also some `.ipynb` files which serve as the source for some of our tutorials. These are converted to MDX via a custom script (`yarn convert-notebooks`). If you want to make changes to these, you will need to install the `nbconvert` Python package in order to preview your changes.
883849

884-
Generate API docs for all languages via:
885-
886-
```bash
887-
cd docs
888-
make html
889-
```
890-
891-
Generate only the main .rst based documentation:
892-
893-
```bash
894-
cd docs
895-
make rsthtml
896-
```
897-
898-
If changing existing Python APIs or adding new APIs under existing
899-
modules, ensure that references to the modified APIs are updated in
900-
existing docs under `docs/source`. Note that the Python doc generation
901-
process will automatically produce updated API docs, but you should
902-
still audit for usages of the modified APIs in guides and examples.
903-
904-
If adding a new public Python module, create a corresponding doc file
905-
for the module under `docs/source/python_api` - [see
906-
here](https://github.com/mlflow/mlflow/blob/v0.9.1/docs/source/python_api/mlflow.tracking.rst#mlflowtracking)
907-
for an example.
908-
909-
> Note: If you are experiencing issues with rstcheck warning of failures in files that you did not modify, try:
910-
911-
```bash
912-
cd docs
913-
make clean; make html
914-
```
850+
For more detailed information, please check the [README.md](https://github.com/mlflow/mlflow/blob/master/docs/README.md) in the `docs/` folder. We're looking forward to your contributions!
915851

916852
### Sign your work
917853

docs/README.md

+20-38
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,39 @@
1-
# MLflow Docusaurus Migration
1+
# MLflow Documentation
22

3-
The `docusaurus` branch is the working branch for all Docusaurus migration work. We are switching away from Sphinx for our main informational docs, and using [Docusaurus](https://docusaurus.io/) instead.
3+
This README covers information about the main MLflow documentation. The API reference is built separately and included as a static folder during the full build process. Please check out the [README](https://github.com/mlflow/mlflow/blob/master/docs/api_reference/README.md) in the `api_reference` folder for more information.
44

5-
## Jobs to be Done
5+
## Prerequisites
66

7-
1. Migrating all non-API related docs from `.rst` to `.mdx`, the Docusaurus format
8-
a. These files can be found in the `rst_to_migrate` folder
9-
2. Migrating notebooks to be rendered via [this plugin](https://github.com/datalayer/jupyter-ui/tree/main/packages/docusaurus-plugin), rather than by `nbsphinx`
10-
a. Notebooks are also found in the `rst_to_migrate` folder, but will end in `.ipynb`
7+
**Necessary**
8+
- NodeJS >= 18.0 (see the [NodeJS documentation](https://nodejs.org/en/download) for installation instructions)
119

12-
### Installation
10+
**Optional**
11+
- (For building MDX files from `.ipynb` files) Python 3.9+ and [nbconvert](https://pypi.org/project/nbconvert/).
12+
- (For building API docs) See [doc-requirements.txt](https://github.com/mlflow/mlflow/blob/master/requirements/doc-requirements.txt) for API doc requirements.
13+
14+
## Installation
1315

1416
```
1517
$ yarn
1618
```
1719

18-
### Local Development
20+
## Local Development
1921

2022
```
2123
$ yarn start
2224
```
2325

2426
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
2527

26-
### Build
27-
28-
```
29-
$ yarn build
30-
```
31-
32-
This command generates static content into the `build` directory and can be served using any static contents hosting service.
33-
34-
### Formatting
35-
36-
```
37-
$ yarn format
38-
```
39-
40-
This command automatically formats all `.mdx` files within the `/docs` folder
41-
42-
43-
### Deployment
28+
**Note**: Some server-side rendering features will not work in this mode (e.g. the [client redirects plugin](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-client-redirects)). To test these, please use the "Build and Serve" workflow below.
4429

45-
Using SSH:
30+
## Build and Serve
4631

47-
```
48-
$ USE_SSH=true yarn deploy
49-
```
50-
51-
Not using SSH:
52-
53-
```
54-
$ GIT_USER=<Your GitHub username> yarn deploy
55-
```
32+
In order to build the full MLflow documentation (i.e. the contents of https://mlflow.org/docs/latest/), please follow the following steps:
5633

57-
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
34+
1. Run `yarn build-api-docs` in order to build the API reference and copy the generated HTML to `static/api_reference`.
35+
a. To speed up the build locally, you can run `yarn build-api-docs:no-r` to skip building R documentation
36+
2. Run `yarn convert-notebooks` to convert `.ipynb` files to `.mdx` files. The generated files are git-ignored.
37+
3. **⚠️ Important!** Run `export DOCS_BASE_URL=/docs/latest` (or wherever the docs are expected to be served). This configures the [Docusaurus baseUrl](https://docusaurus.io/docs/api/docusaurus-config#baseUrl), and the site may not render correctly if this is improperly set.
38+
4. Finally, run `yarn build`. This generates static files in the `build` directory, which can then be served.
39+
5. (Optional) To serve the artifacts generated in the above step, run `yarn serve`.

docs/api_reference/README.md

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# MLflow API Documentation
2+
3+
This directory contains the MLflow API reference. The source code (`.rst` files) is relatively minimal, as the API docs are mainly populated by docstrings in the MLflow Python source.
4+
5+
## Building the docs
6+
7+
First, install dependencies for building docs as described in the [Environment Setup and Python configuration](https://github.com/mlflow/mlflow/blob/master/CONTRIBUTING.md#environment-setup-and-python-configuration) section of the main MLflow contribution guide.
8+
9+
Building documentation requires [Pandoc](https://pandoc.org/index.html). It should have already been
10+
installed if you used the automated env setup script
11+
([dev-env-setup.sh](https://github.com/mlflow/mlflow/blob/master/dev/dev-env-setup.sh)),
12+
but if you are manually installing dependencies, please follow [the official instruction](https://pandoc.org/installing.html).
13+
14+
Also, check the version of your installation via `pandoc --version` and ensure it is 2.2.1 or above.
15+
If you are using Mac OSX, be aware that the Homebrew installation of Pandoc may be outdated. If you are using Linux,
16+
you should use a deb installer or install from the source, instead of running `apt` / `apt-get` commands. Pandoc package available on official
17+
repositories is an older version and contains several bugs. You can find newer versions at <https://github.com/jgm/pandoc/releases>.
18+
19+
To generate a live preview of Python & other rst documentation, run the
20+
following snippet. Note that R & Java API docs must be regenerated
21+
separately after each change and are not live-updated; see subsequent
22+
sections for instructions on generating R and Java docs.
23+
24+
```bash
25+
cd docs
26+
make livehtml
27+
```
28+
29+
Generate R API rst doc files via:
30+
31+
```bash
32+
cd docs
33+
make rdocs
34+
```
35+
36+
---
37+
38+
**NOTE**
39+
40+
If you attempt to build the R documentation on an ARM-based platform (Apple silicon M1, M2, etc.)
41+
you will likely get an error when trying to execute the Docker build process for the make command.
42+
To address this, set the default docker platform environment variable as follows:
43+
44+
```bash
45+
export DOCKER_DEFAULT_PLATFORM=linux/amd64
46+
```
47+
48+
---
49+
50+
Generate Java API rst doc files via:
51+
52+
```bash
53+
cd docs
54+
make javadocs
55+
```
56+
57+
Generate API docs for all languages via:
58+
59+
```bash
60+
cd docs
61+
make html
62+
```
63+
64+
Generate only the main .rst based documentation:
65+
66+
```bash
67+
cd docs
68+
make rsthtml
69+
```
70+
71+
After running these commands, a build folder containing the generated
72+
HTML will be generated at `build/html`.
73+
74+
If changing existing Python APIs or adding new APIs under existing
75+
modules, ensure that references to the modified APIs are updated in
76+
existing docs under `docs/source`. Note that the Python doc generation
77+
process will automatically produce updated API docs, but you should
78+
still audit for usages of the modified APIs in guides and examples.
79+
80+
If adding a new public Python module, create a corresponding doc file
81+
for the module under `docs/source/python_api` - [see
82+
here](https://github.com/mlflow/mlflow/blob/v0.9.1/docs/source/python_api/mlflow.tracking.rst#mlflowtracking)
83+
for an example.
84+
85+
> Note: If you are experiencing issues with rstcheck warning of failures in files that you did not modify, try:
86+
87+
```bash
88+
cd docs
89+
make clean; make html
90+
```

docs/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"start": "docusaurus start",
88
"preview": "yarn build && yarn serve",
99
"build": "docusaurus build",
10-
"build-api-docs": "python scripts/build-api-docs.py --with-r",
11-
"build-api-docs:no-r": "python scripts/build-api-docs.py",
10+
"build-api-docs": "python scripts/build-api-docs.py --with-r && tsx scripts/update-api-modules.ts",
11+
"build-api-docs:no-r": "python scripts/build-api-docs.py && tsx scripts/update-api-modules.ts",
1212
"update-api-modules": "tsx scripts/update-api-modules.ts",
1313
"convert-notebooks": "python scripts/convert-notebooks.py",
1414
"swizzle": "docusaurus swizzle",

0 commit comments

Comments
 (0)