Git Product home page Git Product logo

docs's Introduction

MegEngine Documents

Prerequisites

  • Install sphinx>=2.0 and related dependencies by:

    pip3 install -U sphinx sphinx-autodoc-typehints sphinx-serve sphinxcontrib-jupyter nbsphinx jieba
    pip3 install git+https://github.com/pandas-dev/pydata-sphinx-theme.git@master
    
  • reStructuredText (RST) is used for document writing. HTML files can be generated from the RST files for document visualization.

    For more information about RST, please visit https://sphinx-doc-zh.readthedocs.io/en/latest/rest.html.

Generate API document

  1. Make sure you have installed MegEngine.

    pip3 install megengine -f https://megengine.org.cn/whl/mge.html
  2. Run gen_python_docs/gendoc.sh to generate HTML files. The script accepts the previous python site-packages directory as the argument. Default value is ~/.local/lib/python3.6/site-packages. Note that the RST files generated from python docstring are put under source/autogen.

    ./gen_python_docs/gendoc.sh ~/.local/lib/python3.6/site-packages
  3. Start local sphinx service by:

    sphinx-serve -b build -p 8000

Write python API document

  • How documents are generated for python codes

    1. Write comments following docstring rules.
    2. Run sphinx tool to generate RST files from python docstring.
    3. Generate HTML files from RST.

    Refer to gen_python_docs/gendoc.sh for more details.

  • Example python docstring: see gen_python_docs/example/example.py.

Run doctest in API document

API docstring also contains examples written by doctest. Run the tests by

gen_python_docs/gendoc.sh ~/.local/lib/python3.6/site-packages
sphinx-build -b doctest source build/doctest

If all tests are passed, you shall see the following similar printouts:

Doctest summary
===============
   16 tests
    0 failures in tests
    0 failures in setup code
    0 failures in cleanup code
build succeeded.

Otherwise, please fix any failed test or warning.

docs's People

Contributors

megvii-mge avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.