Skip to content
This repository was archived by the owner on Nov 1, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
# TODO: Investigate errors during first build
# SPHINXOPTS ?= -W --keep-going -n
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

# serves html version of documentation
serve:
cd build/html && http-server -v

# start a watch process that automatically rebuilds the HTML version of
# the doc every time a file is changed in the `source` folder
watch:
watchexec -w .. -e md,rst,py $(MAKE) html
109 changes: 109 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
import datetime

project = 'Metaseq'
copyright = f'{datetime.datetime.now().year} , Meta'
author = 'Meta Research'

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
from glob import glob
import os
import shutil
import sys

sys.path.insert(0, os.path.abspath('../..'))

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"myst_parser",
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
'sphinx_copybutton',
"sphinx_design",
"sphinxcontrib.mermaid",
]

myst_enable_extensions = [
"amsmath",
"colon_fence",
"deflist",
"dollarmath",
"fieldlist",
"html_admonition",
"html_image",
"linkify",
"replacements",
"smartquotes",
"strikethrough",
"substitution",
"tasklist",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

suppress_warnings = ["myst.strikethrough"]

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "furo"
html_title = "Metaseq Documentation"
html_theme_options = {
"source_repository": "https://github.com/facebookresearch/metaseq",
"source_branch": "main",
"source_directory": "docs/source",
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_css_files = ["custom.css"]

# html_logo = "_static/images/logo.svg"
# html_favicon = '_static/images/logo.svg'

autodoc_typehints = 'none'
autodoc_member_order = 'groupwise'
autodoc_default_options = {
'members': True,
'member-order': 'bysource',
'special-members': '__init__',
'exclude-members': '__weakref__'
}

# allows us to automatically link to documentation from other libraries
intersphinx_mapping = {
"numpy": ("http://docs.scipy.org/doc/numpy/", None),
"python": ("https://docs.python.org/3.8", None),
"torch": ("https://pytorch.org/docs/master/", None),
}

# -- LaTeX output -------------------------------------------------

latex_engine = "xelatex"
17 changes: 17 additions & 0 deletions docs/source/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
sd_hide_title: true
---

# Dummy Title

```{toctree}
:hidden:
:caption: Modifying This Documentation
:glob:

modifying_documentation/*
```

# Metaseq

Link to <a href="https://github.com/facebookresearch/metaseq" target="_blank">MetaSeq</a> repo
21 changes: 21 additions & 0 deletions docs/source/modifying_documentation/autodoc_syntax_example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Embed Module or Function members

% For explanation of the autodoc generator check out: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html

## Module Members

```{eval-rst}
.. automodule:: metaseq.cli.train
:members:
```

## Method Members

```{eval-rst}
.. automodule:: metaseq.cli.validate
.. automethod:: metaseq.cli.validate.main(cfg, override_args)

.. .. autoclass:: Run
.. :inherited-members:
.. :members:
```
9 changes: 9 additions & 0 deletions docs/source/modifying_documentation/interdoc_links_example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Linking to other Sphinx documentation

You can link between Sphinx documentation using a `{ref}` instead of a typical URL.

## Examples

- {ref}`Custom Link Text (Torch Utilities) <torch:torch:utilities>`
- {ref}`torch:generated/torch.cuda.streamcontext:streamcontext`
- {ref}`torch:community/contribution_guide:getting started`
31 changes: 31 additions & 0 deletions docs/source/modifying_documentation/mermaid_example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Example using Mermaid

[Mermaid](https://mermaid.js.org/intro/) is a JavaScript based diagramming and charting tool that uses Markdown-inspired text definitions and a renderer to create and modify complex diagrams.

(section-two)=
## Here's another section

% This comment won't make it into the outputs!

And here's {ref}`a reference to this section <section-two>`.
I can also reference the section {ref}`section-two` without specifying my title.

:::{note}
And here's a note with a colon fence!
:::

And finally, here's a cool mermaid diagram!

```{mermaid}
sequenceDiagram
participant Alice
participant Bob
Alice->John: Hello John, how are you?
loop Healthcheck
John->John: Fight against hypochondria
end
Note right of John: Rational thoughts <br/>prevail...
John-->Alice: Great!
John->Bob: How about you?
Bob-->John: Jolly good!
```
40 changes: 40 additions & 0 deletions docs/source/modifying_documentation/overview.md

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you can see in the video of PR description, our documentation has many more files, but I removed almost all of them except for this PR

This folder to demonstrates how to use rST and markdown syntax within Sphinx to achieve what you want.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Overview

## Background

- HTML Documentation is generated using <a href="https://www.sphinx-doc.org/en/master/" target="_blank">Sphinx</a>
- Theme: [Furo](https://pradyunsg.me/furo/reference/)
- Here you find information about the reST or Markdown syntax processed by the theme
- Extensions:
- Support for <a href="https://www.markdownguide.org/" target="_blank">Markdown (.md)</a> and <a href="https://rstdoc.readthedocs.io/en/latest/readme.html" target="_blank">ReStructured Text (.rst)</a> using [Markedly Structured Text (MyST)](https://myst-parser.readthedocs.io/en/latest/intro.html)
- Support for <a href="https://mermaid.js.org/" target="_blank">Mermaid Diagrams</a>

## Installing Sphinx Dependencies

If using the .devcontainer, this should already be done. However, you can do it manually by installing the `docs` extra:

```bash
# From the root folder of the repo
pip install -e ".[docs]"
```

## Building the Documentation

```bash
# Watch /docs/source folder and rebuild the documentation on file change
make watch
```

This will output to the `/docs/build` folder

## Viewing the Documentation

```bash
# Start server to view the documentation
make serve
```

### Open the URL in command output

http://127.0.0.1:7878/index.html

10 changes: 10 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ def do_setup():
"wandb",
"webdataset==0.1.103",
],
"docs": [
"Sphinx",
"myst-parser==0.18.1",
"sphinxcontrib-mermaid==0.8.1",
"linkify-it-py==2.0.0",
"sphinx-copybutton==0.5.1",
"sphinx_design==0.3.0",
"furo==2022.12.7",
"tabulate==0.9.0",
],
},
ext_modules=extension_modules,
test_suite="tests",
Expand Down