Before updating any documentation, fork the coremltools repository, clone your fork to your computer, and add the remote upstream:
git remote add upstream https://github.com/apple/coremltools.gitCreate a branch for the pull request for your editing changes, and make your changes in that branch. For instructions, see GitHub Standard Fork & Pull Request Workflow.
Core ML Tools documentation is organized as follows:
- Guide and Examples for learning Core ML Tools. To update, see Updating the Guide and Examples Pages.
- API Reference that describes the coremltools API. To update, see Updating the API Reference.
- Core ML Format Specification that describes the protobuf message definitions that comprise the Core ML model format. To update, see Updating the Core ML Format Specification.
In addition, the coremltools repository includes the following:
- Core ML Tools README file for this repository.
- Release Notes for the current release and previous releases.
The Markdown files for Guide and Examples pages are organized in the docs-guides/source folder. The docs-guides/index.rst file provides the table of contents and left-column navigation. To make editing changes, follow these general steps:
-
Fork and clone the repository and create a branch for your changes.
-
To preview the HTML, in the
docs-guidesfolder entermake cleanfollowed bymake html. The Sphinx-generated HTML files appear in thedocs-guides/_build/htmlfolder. Open the preview by double-clickingdocs-guides/_build/html/index.html. -
Commit and push your changes.
-
Create and submit a pull request as described in Contributions and add the docs label to it (see Labels for details).
After the pull request is approved and merged, the changes will appear in the HTML pages as they are updated.
The ReStructured Text (.rst) files for the Core ML Format Specification are organized in the mlmodel/docs/Format folder. Synchronize your editing changes with the corresponding protobuf files in the mlmodel/format folder. The mlmodel/docs/index.rst file provides the table of contents and left-column navigation.
To make editing changes, follow these general steps:
-
Fork and clone the repository and create a branch for your changes.
-
To preview the HTML, in the
mlmodel/docsfolder entermake cleanfollowed bymake html. The Sphinx-generated HTML files appear in themlmodel/docs/_build/htmlfolder. Open the preview by double-clickingmlmodel/docs/_build/html/index.html. -
Commit and push your changes.
-
Create and submit a pull request as described in Contributions and add the docs label to it (see Labels for details).
After the pull request is approved and merged, the changes will appear in the HTML pages as they are updated.
To update the docstrings in the source files for the API Reference, follow these general steps:
-
In your clone
coremltools(root) directory, create a virtual environment or Miniconda environment (for instructions see Installing Core ML Tools). Then do the following:a. Install the requirements for building coremltools, and for building the documentation:
pip install -r reqs/build.pip pip install -r reqs/docs.pip
b. Install coremltools from the repo:
pip install -e . -
Edit the
docstringsin the API source files. You can also edit thecoremltools/docs/index.rstfile and other.rstfiles in thecoremltools/docs/sourcefolder to establish the documentation layout and navigation. -
Commit and push your changes, and create a pull request for your changes as described in Contributions. Submit your pull request when finished.
After the pull request is approved and merged, the changes will appear in the HTML pages as they are updated.
-
Navigate to the
docsfolder and runmake cleanto delete any old HTML files (no effect if there are no HTML files). -
Switch to the
coremltoolsroot folder (parent ofdocs), and run the following script to generate the HTML:zsh ./scripts/build_docs.sh
Warning: Include the
./or the script may not function correctly. -
The HTML files appear in the
docs/_build/htmlfolder. Preview your changes by double-clickingdocs/_build/html/index.html.