Skip to content

Commit 5edcc9d

Browse files
authored
Merge pull request #164 from DeepSpace2/devel
devel to master - Furo docs theme
2 parents 26a2b9c + 7d75957 commit 5edcc9d

File tree

8 files changed

+64
-21
lines changed

8 files changed

+64
-21
lines changed

.readthedocs.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
version: 2
22

3+
formats: all
4+
35
build:
46
os: ubuntu-22.04
57
tools:

docs/commandline_interface.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ Usage
2323
Usage Examples
2424
^^^^^^^^^^^^^^
2525

26-
``$ styleframe --json_path data.json --output_path data.xlsx``
26+
.. code-block:: bash
27+
28+
$ styleframe --json_path data.json --output_path data.xlsx
29+
30+
.. code-block:: bash
31+
32+
$ styleframe --json "[{\"sheet_name\": \"sheet_1\", \"columns\": [{\"col_name\": \"col_a\", \"cells\": [{\"value\": 1}]}]}]"
2733
28-
``$ styleframe --json "[{\"sheet_name\": \"sheet_1\", \"columns\": [{\"col_name\": \"col_a\", \"cells\": [{\"value\": 1}]}]}]"``
2934
3035
.. note:: You may need to use different syntax to pass a JSON string depending on your OS and terminal application.
3136

docs/conf.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,34 @@
44
sys.path.insert(0, os.path.abspath('..'))
55

66
add_module_names = False
7+
78
extensions = [
89
'sphinx.ext.autodoc',
910
'sphinx.ext.intersphinx',
11+
'sphinx.ext.viewcode',
12+
'sphinx_copybutton'
1013
]
11-
html_theme = "sphinx_rtd_theme"
14+
15+
html_theme = 'furo'
16+
17+
html_theme_options = {
18+
"source_repository": "https://github.com/DeepSpace2/styleframe/",
19+
"source_branch": "devel",
20+
"source_directory": "docs/",
21+
"dark_css_variables": {
22+
"color-api-name": "#2b8cee"
23+
},
24+
"light_css_variables": {
25+
"color-api-name": "#2962ff"
26+
}
27+
}
28+
1229
intersphinx_mapping = {
1330
'python': ('https://docs.python.org/3', None),
1431
'pandas': ('https://pandas.pydata.org/docs/', None),
1532
'numpy': ('https://numpy.org/doc/stable/', None)
1633
}
34+
1735
master_doc = 'index'
36+
1837
project = 'styleframe'

docs/installation.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
Installation and testing
22
========================
33

4-
``$ pip install styleframe``
4+
.. code-block:: bash
5+
6+
$ pip install styleframe
57
68
To make sure everything works as expected, run styleframe's unittests:
7-
::
9+
10+
.. code-block:: python
811
912
from styleframe import tests
1013

docs/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
furo
12
openpyxl>=2.5,<4
23
colour>=0.1.5,<0.2
34
jsonschema
45
pandas<3
56
xlrd>=1.0.0,<1.3.0 ; python_version<='3.6'
67
sphinx==7.2.6
7-
sphinx-rtd-theme
8+
sphinx-copybutton

docs/usage_examples.rst

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Basic Usage Examples
33

44
StyleFrame's ``init`` supports all the ways you are used to initiate pandas dataframe.
55
An existing dataframe, a dictionary or a list of dictionaries:
6-
::
6+
7+
.. code-block:: python
78
89
from styleframe import StyleFrame, Styler, utils
910
@@ -12,25 +13,36 @@ An existing dataframe, a dictionary or a list of dictionaries:
1213
Applying a style to rows that meet a condition using pandas selecting syntax.
1314
In this example all the cells in the `col_a` column with the value > 50 will have
1415
blue background and a bold, sized 10 font:
15-
::
1616

17+
.. code-block:: python
1718
18-
sf.apply_style_by_indexes(indexes_to_style=sf[sf['col_a'] > 50],
19-
cols_to_style=['col_a'],
20-
styler_obj=Styler(bg_color=utils.colors.blue, bold=True, font_size=10))
19+
sf.apply_style_by_indexes(
20+
indexes_to_style=sf[sf['col_a'] > 50],
21+
cols_to_style=['col_a'],
22+
styler_obj=Styler(
23+
bg_color=utils.colors.blue,
24+
bold=True,
25+
font_size=10
26+
)
27+
)
2128
2229
Creating ExcelWriter object:
23-
::
30+
31+
.. code-block:: python
2432
2533
ew = StyleFrame.ExcelWriter(r'C:\my_excel.xlsx')
2634
sf.to_excel(ew)
2735
ew.close()
2836
2937
It is also possible to style a whole column or columns, and decide whether to style the headers or not:
30-
::
3138

32-
sf.apply_column_style(cols_to_style=['a'], styler_obj=Styler(bg_color=utils.colors.green),
33-
style_header=True)
39+
.. code-block:: python
40+
41+
sf.apply_column_style(
42+
cols_to_style=['a'],
43+
styler_obj=Styler(bg_color=utils.colors.green),
44+
style_header=True
45+
)
3446
3547
Accessors
3648
---------
@@ -39,7 +51,8 @@ Accessors
3951
^^^^^^
4052

4153
Combined with `.loc`, allows easy selection/indexing based on style. For example:
42-
::
54+
55+
.. code-block:: python
4356
4457
only_rows_with_yellow_bg_color = sf.loc[sf['col_name'].style.bg_color == utils.colors.yellow]
4558
only_rows_with_non_bold_text = sf.loc[~sf['col_name'].style.bold]

styleframe/style_frame.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def read_excel(cls, path: str, sheet_name: Union[str, int] = 0, read_style: bool
171171
172172
.. note:: Using ``use_openpyxl_styles=False`` is useful if you are going to filter columns or rows by style, for example:
173173
174-
::
174+
.. code-block:: python
175175
176176
sf = sf[[col for col in sf.columns if col.style.font == utils.fonts.arial]]
177177
@@ -383,7 +383,7 @@ def to_excel(self, excel_writer: Union[str, pd.ExcelWriter, pathlib.Path] = 'out
383383
column. However this isn't guaranteed to work for all fonts (works best with monospaced fonts). The formula
384384
used to calculate a column's width is equivalent to
385385
386-
::
386+
.. code-block:: python
387387
388388
(len(longest_value_in_column) + A_FACTOR) * P_FACTOR
389389
@@ -617,7 +617,7 @@ def apply_style_by_indexes(self,
617617
:param indexes_to_style: Indexes to which the provided style will be applied.
618618
Usually passed as pandas selecting syntax. For example,
619619
620-
::
620+
.. code-block:: python
621621
622622
sf[sf['some_col'] == 20]
623623

styleframe/styler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,13 @@ def combine(cls, *styles: 'Styler'):
301301
Used to combine :class:`Styler` objects. The right-most object has precedence.
302302
For example:
303303
304-
::
304+
.. code-block:: python
305305
306306
Styler.combine(Styler(bg_color='yellow', font_size=24), Styler(bg_color='blue'))
307307
308308
will return
309309
310-
::
310+
.. code-block:: python
311311
312312
Styler(bg_color='blue', font_size=24)
313313

0 commit comments

Comments
 (0)