sphinx 字符串转html,使用sphinx生成美观的文档

先上效果图

f0a8965f19a3b48a4c9513ef93ebf49c.png

详情

首先,须要知道什么是restructuredtext。能够理解为类似于markdown的一个东西。

然后

安装。pip install sphinx

进入存放文档的文件夹,在命令行,sphinx-quickstart,依据须要一路回车。会生成一堆东西,包含conf.py和make等

依据须要改动conf.py

编写rst文件。比方默认的index.rst或链接的rst文件。

在命令行,make html

上图的效果,是使用了一个主题叫sphinx_bootstrap_theme。

(PS.有非常多主题能够选择)

conf.py中关于这个主题的配置是加了以下几行代码

import sphinx_bootstrap_theme

html_theme = 'bootstrap'

html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()

html_theme_options = {

'navbar_title': "Sandglass",

'globaltoc_depth': 2,

'globaltoc_includehidden': "true",

'navbar_class': "navbar navbar-inverse",

'navbar_fixed_top': "true",

'bootswatch_theme': "united",

'bootstrap_version': "3",

}

生成的文档的目录布局

a0c02573a5153b4fdb87b651ea441e45.png

图中的index.rst文件

Welcome to sandglass's documentation!

=====================================

安装

------------

pip install sandglass

概览

--------

**sandglass(沙漏)** 是一个增强的、友好的时间处理库。目的是为了解放程序猿的生产力。

在python中有太多处理时间的库,datetime/date/time/calendar等等。须要记的细节太多,选择困难。

而sandglass就是解决这个的青霉素。从各种麻烦的转换中解脱出来。

仅仅需记住 **Sandglass对象** 和 **ben()** 、 **tslice()** 、 **cronwalk()** 这几个基本的api就可以。

特性

----------

+ api简洁。开箱即用

+ 增强接管datetime

+ (此次略去xx字)

高速上手

---------

在sandglass中,核心对象是 **Sandglass对象** 。通过这个对象。能够方便的获取各个时间属性和操作::

#获取属性

>>>sg = ben('2013,1,1 13:14:15')

>>>sg.year,sg.month,sg.day,sg.hour,sg.minute,sg.second,sg.microsecond

(2013, 1, 1, 13, 14, 15, 0)

(此次略去xx字)

API文档

-----------------

.. toctree::

:maxdepth: 2

api

Todo

---------

* Add timezone support

Changelog

---------

**0.0.1**

* Initial release

Indices and tables

==================

* :ref:`genindex`

* :ref:`modindex`

* :ref:`search`

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值