align latex 使用_使用ReadtheDocs托管文档

使用ReadtheDocs托管文档

一、安装Python

1、搜索python

cb480c4d165bd0e06b97bfb76db40bc8.png

ce22af89894911721f6b5acbadc37e92.png

d4b5d9ae50c7f35adc6de0055747f8c0.png

2、安装

0ec4103f072381838244cc25b7bc99c3.png

Add python 3.8 to PATH 自动给环境变量添加python的路径

b78ed4dcfb7ac8020891a820c9ce42de.png

表示成功

3、验证

Win+R 打开cmd输入python

c8af42b4c795bfed12f7cd872fedc10e.png

二、安装Sphinx

Sphinx 生成文档,Sphinx 最早只是用来生成 Python 官方文档,随着工具的完善, 越来越多的知名的项目也用他来生成文档

1、安装Sphinx

pip install sphinx sphinx-autobuild sphinx_rtd_theme

2.初始化

window下:

d:cd scrapy-cookbook/sphinx-quickstar

linux下

# 创建文档根目录mkdir -p /root/work/scrapy-cookbookcd scrapy-cookbook/# 可以回车按默认配置来写sphinx-quickstart

下面是我填写的,其他基本上默认即可:

> Separate source and build directories (y/n) [n]:y> Project name: WangScaler> Author name(s): WangScaler> Project version []: 0.2> Project release [1.0]: 0.2.2> Project language [en]: zh_CN

安装软件tree查看目录树结构:

windows

tree

linux

yum install treetree -C .

三、支持markdown编写

pip install recommonmarkpip install sphinx-markdown-tables

然后更改conf.py,我的配置如下:

# Configuration file for the Sphinx documentation builder.## This file only contains a selection of the most common options. For a full# list see the documentation:# https://www.sphinx-doc.org/en/master/usage/configuration.html# -- 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.#import osimport sysimport shlexsys.path.insert(0, os.path.abspath('.'))import recommonmarkfrom recommonmark.transform import AutoStructify# -- Project information -----------------------------------------------------source_suffix = ['.rst', '.md']master_doc = 'index'project = 'Interface'copyright = '2020, WangScaler'author = 'WangScaler'version = recommonmark.__version__# The full version, including alpha/beta/rc tagsrelease = recommonmark.__version__# -- 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 = [    'sphinx.ext.autodoc',    'sphinx.ext.napoleon',    'sphinx.ext.mathjax',    'recommonmark',    'sphinx_markdown_tables',]# Add any paths that contain templates here, relative to this directory.templates_path = ['_templates']# The language for content autogenerated by Sphinx. Refer to documentation# for a list of supported languages.## This is also used if you do content translation via gettext catalogs.# Usually you set "language" from the command line for these cases.language = 'zh_CN'# 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']default_role = Nonepygments_style = 'sphinx'todo_include_todos = False# -- 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 = 'sphinx_rtd_theme'# 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']htmlhelp_basename = 'Recommonmarkdoc'latex_elements = {# The paper size ('letterpaper' or 'a4paper').#'papersize': 'letterpaper',# The font size ('10pt', '11pt' or '12pt').#'pointsize': '10pt',# Additional stuff for the LaTeX preamble.#'preamble': '',# Latex figure (float) alignment#'figure_align': 'htbp',}# Grouping the document tree into LaTeX files. List of tuples# (source start file, target name, title,#  author, documentclass [howto, manual, or own class]).latex_documents = [  (master_doc, 'Recommonmark.tex', u'Recommonmark Documentation',   u'Lu Zero, Eric Holscher, and contributors', 'manual'),]man_pages = [    (master_doc, 'recommonmark', u'Recommonmark Documentation',     [author], 1)]texinfo_documents = [  (master_doc, 'Recommonmark', u'Recommonmark Documentation',   author, 'Recommonmark', 'One line description of project.',   'Miscellaneous'),]# At the bottom of conf.py# def setup(app):#     app.add_config_value('recommonmark_config', {#         #'url_resolver': lambda url: github_doc_root + url,#         'auto_toc_tree_section': 'Contents',#         'enable_math': False,#         'enable_inline_math': False,#         'enable_eval_rst': True,#         'enable_auto_doc_ref': True,#     }, True)#     app.add_transform(AutoStructify)

1、编写文件

在source目录下新建hello.rst,内容如下:

# My New Learning## 一、Mongo(Montor异步数据库)

2、修改index.rst文件

.. Test documentation master file, created by   sphinx-quickstart on Mon Jul 20 09:49:03 2020.   You can adapt this file completely to your liking, but it should at least   contain the root `toctree` directive.Welcome to Interface Document!================================.. toctree::   :maxdepth: 2   :caption: 名字:   helloIndices and tables==================* :ref:`genindex`* :ref:`modindex`* :ref:`search`

2、执行文件

在根目录执行make html

3、预览效果

进入build/html目录后用浏览器打开index.html

四、遇到的问题

1.图片不显示

解决方案:1、图片使用图床加载、

2、使用相对路径,如/images/a.jpg

3、注意路径是/而非\第二种不可行

2.表格不显示

pip install sphinx-markdown-tables

在conf.py文件中修改

extensions = [    'sphinx.ext.autodoc',    'sphinx.ext.napoleon',    'sphinx.ext.mathjax',    'recommonmark',    'sphinx_markdown_tables',#这句话支持markdown表格]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值