Skip to content

Commit c8b9c20

Browse files
committed
Doc improvement
1 parent d1d3870 commit c8b9c20

9 files changed

Lines changed: 71 additions & 38 deletions

File tree

ctools/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class Channel:
137137

138138

139139
class SortedMap:
140-
def __init__(self, capacity: int = MAX_INT32) -> None: ...
140+
def __init__(self, cmp: Callable[[Any], int] = None) -> None: ...
141141

142142
def __getitem__(self, item): ...
143143

docs/_static/custom.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@import url("https://fonts.googleapis.com/css?family=Inconsolata");
2+
3+
body, pre, tt, code {
4+
font-family: "Inconsolata", monospace, monospace;
5+
font-variant-ligatures: discretionary-ligatures;
6+
}

docs/api.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ API
77

88
Functions
99
---------
10-
------------
1110

1211
.. autofunction:: strhash
1312

@@ -20,7 +19,6 @@ Functions
2019

2120
Classes
2221
-------
23-
------------
2422

2523
.. autoclass:: CacheMap
2624
:members:

docs/conf.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# add these directories to sys.path here. If the directory is relative to the
1111
# documentation root, use os.path.abspath to make it absolute, like shown here.
1212
#
13+
import datetime
1314
import os
1415
import sys
1516

@@ -30,8 +31,9 @@ def get_version():
3031

3132

3233
# -- Project information -----------------------------------------------------
33-
project = "ctools"
34-
copyright = "2019, ko-han"
34+
build_at = datetime.date.today().strftime("%a %b %d %Y")
35+
project = "CTools"
36+
copyright = "2019, ko-han. Last updated on " + build_at
3537
author = "ko-han"
3638

3739
# The full version, including alpha/beta/rc tags
@@ -61,6 +63,14 @@ def get_version():
6163

6264
pygments_style = "sphinx"
6365

66+
rst_epilog = """\n
67+
.. |ProjectVersion| replace:: {version}
68+
.. |ProjectName| replace:: {project}
69+
.. |BuildAt| replace:: {build_at}
70+
""".format(
71+
project=project, version=version, build_at=build_at,
72+
)
73+
6474
# -- Options for HTML output -------------------------------------------------
6575

6676
# The theme to use for HTML and HTML Help pages. See the documentation for
@@ -75,12 +85,30 @@ def get_version():
7585

7686
html_title = "%s v%s Manual" % (project, version)
7787

78-
# -- sphinx.ext.autodoc -----------------------------------------------------
88+
font_family = '"Inconsolata", monospace, monospace'
89+
description = (
90+
"A collection of useful data structures and functions written in C for Python."
91+
)
92+
html_theme_options = {
93+
"github_user": "ko-han",
94+
"github_repo": "python-ctools",
95+
"github_banner": "false",
96+
"github_button": "true",
97+
"description": description,
98+
"fixed_sidebar": "true",
99+
"show_relbars": "true",
100+
"code_font_family": font_family,
101+
"font_family": font_family,
102+
"head_font_family": font_family,
103+
}
104+
105+
# -- sphinx.ext.autodoc ------------------------------------------------------
79106
autodoc_docstring_signature = True
80107
autodoc_default_flags = ["members"]
81108
autoclass_content = "class"
109+
autosummary_generate = True
82110

83-
numpydoc_show_class_members = True
111+
numpydoc_show_class_members = False
84112
numpydoc_class_members_toctree = True
85113
numpydoc_xref_param_type = True
86114

docs/index.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
.. ctools documentation master file, created by
2-
sphinx-quickstart on Mon Sep 23 00:12:18 2019.
3-
You can adapt this file completely to your liking, but it should at least
4-
contain the root `toctree` directive.
1+
CTools Documentation
2+
====================
53

6-
Welcome to ctools's documentation!
7-
==================================
4+
Welcome! This is the documentation for |ProjectName| |ProjectVersion|, last updated |BuildAt|.
85

96

107
Install

src/cachemap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ static PyObject *CacheMap_tp_richcompare(PyObject *self, PyObject *other,
744744
}
745745

746746
PyDoc_STRVAR(CacheMap__doc__, "CacheMap(maxsize=None, /)\n\n"
747-
"A fast CacheMap behaving much like dict.\n\n"
747+
"A fast LFU (least frequently used) mapping.\n\n"
748748
"Default max size is C ``INT32_MAX``.\n\n"
749749
"Examples\n"
750750
"--------\n"

src/channel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ static PyMethodDef Channel_methods[] = {
467467
};
468468

469469
PyDoc_STRVAR(Channel_Doc, "Channel(size=None, /)\n\n"
470-
"A channel support send and safe resume.\n"
470+
"A channel support sending and safe consuming.\n"
471471
"Default size is C ``MAX_INT32``\n\n"
472472
"Examples\n"
473473
"--------\n"

src/rbtree.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,13 +1210,16 @@ static PyObject *RBTree_tp_iter(CtsRBTree *tree) {
12101210

12111211
PyDoc_STRVAR(RBTree__doc__,
12121212
"SortedMap(cmp=None, /)\n\n"
1213-
"A sorted map base on red-black tree.\n"
1214-
"`cmp` is a optional callable receive two keys, and "
1215-
"return negative integer if `k1 < k2`, "
1216-
"return positive integer if `k1 > k2`, "
1217-
"return 0 if `k1 == k2`.\n"
1218-
"It's every similar to standard C library qsort comparator.\n"
1219-
"\n.. versionadded:: 0.2.0\n"
1213+
"A sorted map base on red-black tree.\n\n"
1214+
".. versionadded:: 0.2.0\n"
1215+
"Parameters\n"
1216+
"----------\n"
1217+
"cmp : typing.Callable[[typing.Any], int]\n"
1218+
" A optional callable receive two keys, that\n"
1219+
" return negative integer if `k1 < k2`, \n"
1220+
" return positive integer if `k1 > k2`, \n"
1221+
" return 0 if `k1 == k2`.\n"
1222+
" It's every similar to standard C library qsort comparator.\n"
12201223
"\n"
12211224
"Examples\n"
12221225
"--------\n"

src/ttlcache.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -629,22 +629,23 @@ static PyObject *TTLCache_tp_richcompare(PyObject *self, PyObject *other,
629629
}
630630
}
631631

632-
PyDoc_STRVAR(TTLCache__doc__, "TTLCache(ttl=None)\n\n"
633-
"A fast TTLCache behaving much like dict. All "
634-
"key will expire after `ttl` seconds.\n"
635-
"\n"
636-
"Default ttl is 1 minute.\n\n"
637-
"Examples\n"
638-
"--------\n"
639-
">>> import ctools\n"
640-
">>> import time\n"
641-
">>> cache = ctools.TTLCache(5)\n"
642-
">>> cache['foo'] = 'bar'\n"
643-
">>> cache['foo']\n"
644-
"'bar'\n"
645-
">>> time.sleep(5)\n"
646-
">>> 'foo' in cache\n"
647-
"False\n");
632+
PyDoc_STRVAR(
633+
TTLCache__doc__,
634+
"TTLCache(ttl=None)\n\n"
635+
"A mapping that keys expire and unreachable after ``ttl`` seconds.\n"
636+
"\n"
637+
"Default ``ttl`` is 1 minute.\n\n"
638+
"Examples\n"
639+
"--------\n"
640+
">>> import ctools\n"
641+
">>> import time\n"
642+
">>> cache = ctools.TTLCache(5)\n"
643+
">>> cache['foo'] = 'bar'\n"
644+
">>> cache['foo']\n"
645+
"'bar'\n"
646+
">>> time.sleep(5)\n"
647+
">>> 'foo' in cache\n"
648+
"False\n");
648649

649650
static PyTypeObject TTLCache_Type = {
650651
/* clang-format off */

0 commit comments

Comments
 (0)