Skip to content

Commit aeb9c0e

Browse files
committed
rtd initial docs test
1 parent 271e0f3 commit aeb9c0e

File tree

6 files changed

+256
-0
lines changed

6 files changed

+256
-0
lines changed

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/source/api.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
API
2+
===
3+
4+
.. autosummary::
5+
:toctree: generated
6+
7+
table2ascii

docs/source/conf.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
3+
# -- Project information
4+
5+
project = 'table2ascii'
6+
copyright = '2021, Jonah Lawrence'
7+
author = 'Jonah Lawrence'
8+
9+
release = '0.1.2'
10+
version = '0.1.2'
11+
12+
# -- General configuration
13+
14+
extensions = [
15+
'sphinx.ext.duration',
16+
'sphinx.ext.doctest',
17+
'sphinx.ext.autodoc',
18+
'sphinx.ext.autosummary',
19+
'sphinx.ext.intersphinx',
20+
]
21+
22+
intersphinx_mapping = {
23+
'python': ('https://docs.python.org/3/', None),
24+
'sphinx': ('https://www.sphinx-doc.org/en/master/', None),
25+
}
26+
intersphinx_disabled_domains = ['std']
27+
28+
templates_path = ['_templates']
29+
30+
# -- Options for HTML output
31+
32+
html_theme = 'sphinx_rtd_theme'
33+
34+
# -- Options for EPUB output
35+
epub_show_urls = 'footnote'

docs/source/index.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
table2ascii
2+
===========
3+
4+
|build| |version| |downloads| |license| |Discord|
5+
6+
Module for converting 2D Python lists to fancy ASCII/Unicode tables
7+
8+
Installation
9+
--------------
10+
11+
``pip install -U table2ascii``
12+
13+
**Requirements:** ``Python 3.7+``
14+
15+
16+
.. |build| image:: https://img.shields.io/github/workflow/status/DenverCoder1/table2ascii/Python%20application/main
17+
:target: https://github.com/DenverCoder1/table2ascii/actions/workflows/python-app.yml
18+
.. |version| image:: https://img.shields.io/pypi/v/table2ascii
19+
:target: https://pypi.org/project/table2ascii/
20+
.. |downloads| image:: https://static.pepy.tech/personalized-badge/table2ascii?period=total&units=none&left_color=grey&right_color=orange&left_text=downloads
21+
:target: https://pepy.tech/project/table2ascii
22+
.. |license| image:: https://img.shields.io/pypi/l/table2ascii
23+
:target: https://github.com/DenverCoder1/table2ascii/blob/main/LICENSE
24+
.. |Discord| image:: https://img.shields.io/discord/819650821314052106?color=5865F2&logo=discord&logoColor=white
25+
:target: https://discord.gg/fPrdqh3Zfu

docs/source/usage.rst

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
Usage
2+
---------
3+
4+
Convert lists to ASCII tables
5+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6+
7+
.. code:: py
8+
9+
from table2ascii import table2ascii
10+
11+
output = table2ascii(
12+
header=["#", "G", "H", "R", "S"],
13+
body=[["1", "30", "40", "35", "30"], ["2", "30", "40", "35", "30"]],
14+
footer=["SUM", "130", "140", "135", "130"],
15+
)
16+
17+
print(output)
18+
19+
"""
20+
╔═════════════════════════════╗
21+
║ # G H R S ║
22+
╟─────────────────────────────╢
23+
║ 1 30 40 35 30 ║
24+
║ 2 30 40 35 30 ║
25+
╟─────────────────────────────╢
26+
║ SUM 130 140 135 130 ║
27+
╚═════════════════════════════╝
28+
"""
29+
30+
Set first or last column headings
31+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32+
33+
.. code:: py
34+
35+
from table2ascii import table2ascii
36+
37+
output = table2ascii(
38+
body=[["Assignment", "30", "40", "35", "30"], ["Bonus", "10", "20", "5", "10"]],
39+
first_col_heading=True,
40+
)
41+
42+
print(output)
43+
44+
"""
45+
╔════════════╦═══════════════════╗
46+
║ Assignment ║ 30 40 35 30 ║
47+
║ Bonus ║ 10 20 5 10 ║
48+
╚════════════╩═══════════════════╝
49+
"""
50+
51+
Set column widths and alignments
52+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
53+
54+
.. code:: py
55+
56+
from table2ascii import table2ascii, Alignment
57+
58+
output = table2ascii(
59+
header=["#", "G", "H", "R", "S"],
60+
body=[["1", "30", "40", "35", "30"], ["2", "30", "40", "35", "30"]],
61+
first_col_heading=True,
62+
column_widths=[5] * 5, # [5, 5, 5, 5, 5]
63+
alignments=[Alignment.LEFT] + [Alignment.RIGHT] * 4, # First is left, remaining 4 are right
64+
)
65+
66+
print(output)
67+
68+
"""
69+
╔═════╦═══════════════════════╗
70+
║ # ║ G H R S ║
71+
╟─────╫───────────────────────╢
72+
║ 1 ║ 30 40 35 30 ║
73+
║ 2 ║ 30 40 35 30 ║
74+
╚═════╩═══════════════════════╝
75+
"""
76+
77+
Use a preset style
78+
~~~~~~~~~~~~~~~~~~
79+
80+
.. code:: py
81+
82+
from table2ascii import table2ascii, PresetStyle
83+
84+
output = table2ascii(
85+
header=["First", "Second", "Third", "Fourth"],
86+
body=[["10", "30", "40", "35"], ["20", "10", "20", "5"]],
87+
column_widths=[10] * 4,
88+
style=PresetStyle.ascii_box
89+
)
90+
91+
print(output)
92+
93+
"""
94+
+----------+----------+----------+----------+
95+
| First | Second | Third | Fourth |
96+
+----------+----------+----------+----------+
97+
| 10 | 30 | 40 | 35 |
98+
+----------+----------+----------+----------+
99+
| 20 | 10 | 20 | 5 |
100+
+----------+----------+----------+----------+
101+
"""
102+
103+
Define a custom style
104+
~~~~~~~~~~~~~~~~~~~~~
105+
106+
Check
107+
```TableStyle`` <https://github.com/DenverCoder1/table2ascii/blob/main/table2ascii/table_style.py>`__
108+
for more info and
109+
```PresetStyle`` <https://github.com/DenverCoder1/table2ascii/blob/main/table2ascii/preset_style.py>`__
110+
for examples.
111+
112+
.. code:: py
113+
114+
from table2ascii import table2ascii, TableStyle
115+
116+
my_style = TableStyle.from_string("*-..*||:+-+:+ *''*")
117+
118+
output = table2ascii(
119+
header=["First", "Second", "Third"],
120+
body=[["10", "30", "40"], ["20", "10", "20"], ["30", "20", "30"]],
121+
style=my_style
122+
)
123+
124+
print(output)
125+
126+
"""
127+
*-------.--------.-------*
128+
| First : Second : Third |
129+
+-------:--------:-------+
130+
| 10 : 30 : 40 |
131+
| 20 : 10 : 20 |
132+
| 30 : 20 : 30 |
133+
*-------'--------'-------*
134+
"""

0 commit comments

Comments
 (0)