Keep Markdown ToCs up to date (#54974)

Summary:
This PR uses [markdown-toc](https://github.com/jonschlinkert/markdown-toc#cli) to [automatically update the table of contents for `README.md` and `CONTRIBUTING.md`](https://github.com/pytorch/pytorch/pull/54904#issuecomment-809682134) in CI.

This keeps the same format already used in `README.md`. While it does slightly change the format for the ToC in `CONTRIBUTING.md`, the new format is actually just the same as the old format that was already being used prior to https://github.com/pytorch/pytorch/issues/51458.

Race condition with https://github.com/pytorch/pytorch/issues/54904.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/54974

Test Plan: The new "Lint / toc" job in GitHub Actions [succeeds](https://github.com/pytorch/pytorch/pull/54974/checks?check_run_id=2238739005) on this PR, and [fails](https://github.com/pytorch/pytorch/pull/54976/checks?check_run_id=2238784022) on https://github.com/pytorch/pytorch/issues/54976 with an understandable error message.

Reviewed By: malfet

Differential Revision: D27468390

Pulled By: samestep

fbshipit-source-id: 14a73f42ed546d4310140b94ded14e099185d0e0
This commit is contained in:
Sam Estep 2021-03-31 10:34:38 -07:00 committed by Facebook GitHub Bot
parent 7fc03dd7c9
commit a74b10def9
3 changed files with 90 additions and 41 deletions

View File

@ -57,6 +57,33 @@ jobs:
set -eux
python torch/testing/check_kernel_launches.py |& tee ${GITHUB_WORKSPACE}/cuda_kernel_launch_checks.txt
toc:
runs-on: ubuntu-18.04
# https://github.com/actions/virtual-environments/issues/599#issuecomment-602754687
env:
NPM_CONFIG_PREFIX: ~/.npm-global
steps:
- name: Setup Node
uses: actions/setup-node@v2
- name: Checkout PyTorch
uses: actions/checkout@v2
- name: Install markdown-toc
run: npm install -g markdown-toc
- name: Regenerate ToCs
run: |
set -eux
export PATH=~/.npm-global/bin:"$PATH"
for FILE in {CONTRIBUTING,README}.md; do
markdown-toc --bullets='-' -i "$FILE"
done
- name: Assert that regenerating the ToCs didn't change them
run: |
set -eux
CHANGES=$(git status --porcelain)
echo "$CHANGES"
git diff
[ -z "$CHANGES" ]
flake8-py3:
runs-on: ubuntu-18.04
steps:

View File

@ -1,24 +1,25 @@
# Table of Contents
- [Table of Contents](#table-of-contents)
- [Contributing to PyTorch](#contributing-to-pytorch)
- [Developing PyTorch](#developing-pytorch)
<!-- toc -->
- [Contributing to PyTorch](#contributing-to-pytorch)
- [Developing PyTorch](#developing-pytorch)
- [Tips and Debugging](#tips-and-debugging)
- [Nightly Checkout & Pull](#nightly-checkout--pull)
- [Codebase structure](#codebase-structure)
- [Unit testing](#unit-testing)
- [Nightly Checkout & Pull](#nightly-checkout--pull)
- [Codebase structure](#codebase-structure)
- [Unit testing](#unit-testing)
- [Better local unit tests with pytest](#better-local-unit-tests-with-pytest)
- [Running `mypy`](#running-mypy)
- [Writing documentation](#writing-documentation)
- [Writing documentation](#writing-documentation)
- [Building documentation](#building-documentation)
- [Tips](#tips)
- [Building C++ Documentation](#building-c-documentation)
- [Previewing changes](#previewing-changes)
- [Submitting changes for review](#submitting-changes-for-review)
- [Adding documentation tests](#adding-documentation-tests)
- [Profiling with `py-spy`](#profiling-with-py-spy)
- [Managing multiple build trees](#managing-multiple-build-trees)
- [C++ development tips](#c-development-tips)
- [Profiling with `py-spy`](#profiling-with-py-spy)
- [Managing multiple build trees](#managing-multiple-build-trees)
- [C++ development tips](#c-development-tips)
- [Build only what you need](#build-only-what-you-need)
- [Code completion and IDE support](#code-completion-and-ide-support)
- [Make no-op build fast](#make-no-op-build-fast)
@ -27,20 +28,22 @@
- [Use a faster linker](#use-a-faster-linker)
- [C++ frontend development tips](#c-frontend-development-tips)
- [GDB integration](#gdb-integration)
- [CUDA development tips](#cuda-development-tips)
- [Windows development tips](#windows-development-tips)
- [CUDA development tips](#cuda-development-tips)
- [Windows development tips](#windows-development-tips)
- [Known MSVC (and MSVC with NVCC) bugs](#known-msvc-and-msvc-with-nvcc-bugs)
- [Running clang-tidy](#running-clang-tidy)
- [Pre-commit tidy/linting hook](#pre-commit-tidylinting-hook)
- [Building PyTorch with ASAN](#building-pytorch-with-asan)
- [Running clang-tidy](#running-clang-tidy)
- [Pre-commit tidy/linting hook](#pre-commit-tidylinting-hook)
- [Building PyTorch with ASAN](#building-pytorch-with-asan)
- [Getting `ccache` to work](#getting-ccache-to-work)
- [Why this stuff with `LD_PRELOAD` and `LIBASAN_RT`?](#why-this-stuff-with-ld_preload-and-libasan_rt)
- [Why LD_PRELOAD in the build function?](#why-ld_preload-in-the-build-function)
- [Why no leak detection?](#why-no-leak-detection)
- [Caffe2 notes](#caffe2-notes)
- [CI failure tips](#ci-failure-tips)
- [Caffe2 notes](#caffe2-notes)
- [CI failure tips](#ci-failure-tips)
- [Which commit is used in CI?](#which-commit-is-used-in-ci)
<!-- tocstop -->
## Contributing to PyTorch
Thank you for your interest in contributing to PyTorch! Before you begin writing code, it is important

View File

@ -8,17 +8,36 @@ PyTorch is a Python package that provides two high-level features:
You can reuse your favorite Python packages such as NumPy, SciPy, and Cython to extend PyTorch when needed.
- [More about PyTorch](#more-about-pytorch)
<!-- toc -->
- [More About PyTorch](#more-about-pytorch)
- [A GPU-Ready Tensor Library](#a-gpu-ready-tensor-library)
- [Dynamic Neural Networks: Tape-Based Autograd](#dynamic-neural-networks-tape-based-autograd)
- [Python First](#python-first)
- [Imperative Experiences](#imperative-experiences)
- [Fast and Lean](#fast-and-lean)
- [Extensions Without Pain](#extensions-without-pain)
- [Installation](#installation)
- [Binaries](#binaries)
- [NVIDIA Jetson Platforms](#nvidia-jetson-platforms)
- [From Source](#from-source)
- [Install Dependencies](#install-dependencies)
- [Get the PyTorch Source](#get-the-pytorch-source)
- [Install PyTorch](#install-pytorch)
- [Adjust Build Options (Optional)](#adjust-build-options-optional)
- [Docker Image](#docker-image)
- [Using pre-built images](#using-pre-built-images)
- [Building the image yourself](#building-the-image-yourself)
- [Building the Documentation](#building-the-documentation)
- [Previous Versions](#previous-versions)
- [Getting Started](#getting-started)
- [Resources](#resources)
- [Communication](#communication)
- [Releases and Contributing](#releases-and-contributing)
- [The Team](#the-team)
- [License](#license)
<!-- tocstop -->
| System | 3.6 | 3.7 | 3.8 |
| :---: | :---: | :---: | :--: |