Skip to content

Commit cfafda6

Browse files
committed
Very basic Google style docstrings created that are then used by mkdocs to create content for the pages.
1 parent 6fe2ee1 commit cfafda6

File tree

2 files changed

+39
-27
lines changed

2 files changed

+39
-27
lines changed

tkintermd/tkintermd_constants.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,46 @@
1+
"""Variables and constants to be used by tkintermd."""
12
from pathlib import Path
23

3-
# This is the only variable to be changed from elsewhere. All the rest should
4-
# remain constant.
54
cur_file = Path()
5+
"""Variable for tracking current open file."""
66

77
bold_md_syntax = ("**", "__")
8+
"""Markdown syntax for bold highlighting."""
89
bold_md_ignore = (
910
"- ", "> ", "# ", "`",
1011
"--", ">> ", "## ",
1112
"***", "___", "---", ">>> ", "### ", "```", "===",
1213
"####", "#####", "######",
1314
)
15+
"""Markdown syntax to ignore for bold highlighting."""
1416
italic_md_syntax = ("*", "_")
17+
"""Markdown syntax for italic highlighting."""
1518
italic_md_ignore = (
1619
"**", "__", "- ", "> ", "# ", "`",
1720
"--", ">> ", "## ",
1821
"***", "___", "---", ">>> ", "### ", "```", "===",
1922
"####", "#####", "######",
2023
)
24+
"""Markdown syntax to ignore for italic highlighting."""
2125
# Needs adjusting.
2226
bold_italic_md_syntax = ("***", "___")
27+
"""Markdown syntax for bold-italic highlighting."""
2328
bold_italic_md_ignore = (
2429
"*", "_", "- ", "> ", "# ", "`",
2530
"**", "__", "--", ">> ", "## ",
2631
"***", "___", "---", ">>> ", "### ", "```", "===",
2732
"####", "#####", "######",
2833
)
34+
"""Markdown syntax to ignore for bold-italic highlighting."""
2935
strikethrough_md_syntax = ("~~", "~~")
36+
"""Markdown syntax for strikethrough highlighting."""
3037
strikethrough_md_ignore = (
3138
"*", "_", "- ", "> ", "# ", "`",
3239
"**", "__", "--", ">> ", "## ",
3340
"***", "___", "---", ">>> ", "### ", "```", "===",
3441
"####", "#####", "######",
3542
)
36-
43+
"""Markdown syntax to ignore for strikethrough highlighting."""
3744
default_md_string = """
3845
# Heading 1
3946
## Heading 2
@@ -104,4 +111,5 @@
104111
```
105112
This is a fenced code block.
106113
```
107-
"""
114+
"""
115+
"""Default string to show in editor when it loads."""

tkintermd/tkintermd_frame.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,27 @@
1616
from pygments.styles import get_style_by_name
1717

1818
class TkinterMDFrame(tk.Frame):
19-
def __init__(self, master, **kwargs):
20-
"""
21-
A Markdown editor with HTML Preview window in a tkinter frame. Import it
22-
into your own scripts like so:
23-
24-
from tkintermd.tkintermd_frame import TkinterMDFrame
19+
"""An embeddable tkinter based Markdown editor with HTML preview.
20+
21+
The editor has syntax highlighting supplied by `Pygments` and the HTML
22+
preview window is provided by `tkinterweb`.
23+
24+
Import it into your own scripts like so:
25+
26+
```python
27+
from tkintermd.tkintermd_frame import TkinterMDFrame
2528
26-
import tkinter as tk
27-
from tkinter.constants import *
29+
import tkinter as tk
30+
from tkinter.constants import *
2831
29-
root = tk.Tk()
30-
app = TkinterMDFrame(root)
31-
app.pack(fill="both", expand=1)
32-
app.mainloop()
33-
34-
"""
32+
root = tk.Tk()
33+
app = TkinterMDFrame(root)
34+
app.pack(fill="both", expand=1)
35+
app.mainloop()
36+
```
37+
38+
"""
39+
def __init__(self, master, **kwargs):
3540
tk.Frame.__init__(self, master) # no need for super
3641

3742
# Toolbar.
@@ -190,8 +195,7 @@ def on_scrollbar(self, *args):
190195
# self.preview_area.html.yview(*args)
191196

192197
def on_mousewheel(self, *args):
193-
'''Moves the scrollbar and scrolls text widgets when the mousewheel
194-
is moved on a text widget'''
198+
'''Moves the scrollbar and scrolls the widgets on mousewheel event'''
195199
self.scrollbar.set(*args)
196200
# # This links the scrollbars but is currently causing issues.
197201
# self.preview_area.vsb.set(*args)
@@ -245,8 +249,9 @@ def save_as_md_file(self):
245249
mbox.showerror(title="Error", message=f"Error Saving File\n\nThe file: {self.save_filename_md} can not be saved!")
246250

247251
def save_md_file(self):
248-
"""Quick saves the file with its current name, if it fails because no
249-
name exists it calls the "save_as_md_file" function."""
252+
"""Quick saves the file with its current name.
253+
254+
If it fails because no name exists it calls the "save_as_md_file" function."""
250255
self.file_data = self.text_area.get("1.0" , END)
251256
try:
252257
with open(constants.cur_file, "w") as stream:
@@ -311,12 +316,11 @@ def check_markdown(self, start='insert linestart', end='insert lineend'):
311316
self.text_area.mark_set("range_start", "range_end")
312317

313318
def apply_markdown_both_sides(self, md_syntax, md_ignore):
314-
"""
315-
A generic, catch-all attempt to apply and remove markdown from either
316-
side of a selection.
319+
"""Apply and remove markdown from either side of a selection.
317320
318-
:param md_syntax: Tuple of markdown strings to apply/remove.
319-
:param md_ignore: Tuple of markdown strings to ignore.
321+
Args:
322+
md_syntax (tuple): Tuple of markdown strings to apply/remove.
323+
md_ignore (tuple): Tuple of markdown strings to ignore.
320324
"""
321325
self.md_syntax = md_syntax
322326
self.md_ignore = md_ignore

0 commit comments

Comments
 (0)