Skip to content

Commit

Permalink
Merge pull request #320 from Start-Out/dev/feature/formatted-comment-…
Browse files Browse the repository at this point in the history
…grammar

Feature: TODO Grammar 📑
  • Loading branch information
trentonyo authored Jun 17, 2024
2 parents 265cd92 + 4fa9d14 commit 1f29665
Show file tree
Hide file tree
Showing 26 changed files with 1,654 additions and 715 deletions.
2 changes: 1 addition & 1 deletion .idea/todo-or-not.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Example usage of # todoon
##########################


def an_unfinished_function():
# TODO Finish documenting todo-or-not
print("Hello, I'm not quite done, there's more to do!")
Expand All @@ -16,9 +17,7 @@ def a_broken_function():
# from the line that triggered the issue.
# The search for pertinent lines will stop when it hits a line break or the
# maximum number of lines, set by PERTINENT_LINE_LIMIT
a = [
1, 1, 2, 3
]
a = [1, 1, 2, 3]
b = sum(a)
c = b * len(a)
return c / 0 # FIXME I just don't know why this doesn't work!
Expand All @@ -39,5 +38,7 @@ def a_very_pretty_example():

def a_closed_example():
# TODO Closed Issues are helpful! | This issue is closed, but the TODO string is still in the codebase!
print("This should be a red flag, because if the issue is still in the code then something isn't done yet")
print(
"This should be a red flag, because if the issue is still in the code then something isn't done yet"
)
print("(Though it may simply be that the comment hasn't been removed)")
45 changes: 28 additions & 17 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "todo-or-not"
version = "0.12.8"
version = "0.13.0"
description = "todoon integrates the TODOs in your codebase with your GitHub repository"
authors = ["TrentonYo <trentonyo@gmail.com>"]
license = "GPL-3.0-only"
Expand All @@ -15,6 +15,7 @@ python = "^3.11"
typer = "^0.12.3"
typing-extensions = "^4.10.0"
tqdm = "^4.66.4"
ply = "^3.11"

[tool.poetry.group.testing.dependencies]
coveralls = "^3.3.1"
Expand Down
20 changes: 11 additions & 9 deletions scripts/_update_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
args = sys.argv[1:]

starting_version_string = __version__
major, minor, patch = starting_version_string.split('.')
major, minor, patch = starting_version_string.split(".")
major = int(major)
minor = int(minor)
patch = int(patch)
Expand All @@ -17,18 +17,20 @@
# Increment appropriate version number

if len(args) == 1:
if args[0] == '-a':
if args[0] == "-a":
major += 1
minor = patch = 0
if args[0] == '-i':
if args[0] == "-i":
minor += 1
patch = 0
if args[0] == '-p':
if args[0] == "-p":
patch += 1
else:
print("Usage: _update_versions [-a/-i/-p]\n\nM[a]JOR, M[i]NOR, or [p]ATCH version incremented by one")
print(
"Usage: _update_versions [-a/-i/-p]\n\nM[a]JOR, M[i]NOR, or [p]ATCH version incremented by one"
)

today_string = datetime.today().strftime('%Y-%m-%d')
today_string = datetime.today().strftime("%Y-%m-%d")
semver_string = f"{major}.{minor}.{patch}"

############################
Expand All @@ -37,7 +39,7 @@
_init_path = os.path.join("..", "todo_or_not", "__init__.py")

with open(_init_path, "w") as init_file:
new_contents = f'''import datetime
new_contents = f"""import datetime
#####################################################
# VITAL: SEE /scripts/_update_versions.py !!!
Expand All @@ -50,7 +52,7 @@
iso_string = "{today_string}"
version_date = datetime.date.fromisoformat(iso_string)
'''
"""
init_file.write(new_contents)

############################
Expand All @@ -66,7 +68,7 @@
if line.startswith("version = "):
init_file.seek(last_line)

init_file.write(f"version = \"{semver_string}\"")
init_file.write(f'version = "{semver_string}"')
break

last_line = init_file.tell()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
def a_closed_example():
# TODO Closed Issues are helpful! | This issue is closed, but the TODO string is still in the codebase!
print("This should be a red flag, because if the issue is still in the code then something isn't done yet")
print(
"This should be a red flag, because if the issue is still in the code then something isn't done yet"
)
print("(Though it may simply be that the comment hasn't been removed)")
14 changes: 9 additions & 5 deletions tests/resources/example.txt → tests/resources/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Example usage of # todoon
##########################


def an_unfinished_function():
# TODO Finish documenting todo-or-not
print("Hello, I'm not quite done, there's more to do!")
Expand All @@ -16,9 +17,7 @@ def a_broken_function():
# from the line that triggered the issue.
# The search for pertinent lines will stop when it hits a line break or the
# maximum number of lines, set by PERTINENT_LINE_LIMIT
a = [
1, 1, 2, 3
]
a = [1, 1, 2, 3]
b = sum(a)
c = b * len(a)
return c / 0 # FIXME I just don't know why this doesn't work!
Expand All @@ -29,14 +28,19 @@ def a_broken_function():

def a_skipping_example():
# Since the line below has `# todoon` in it, the checker will give it a pass even though it has the magic words!
print("Sometimes you really have to write TODO or FIXME, like this!") # todoon
print(
"Sometimes you really have to write TODO or FIXME, like this!"
) # Remember to update your todo list! # todoon


def a_very_pretty_example():
# TODO Titled Issue! | In this format, you can define a title and a body! Also labels like #example or #enhancement
print("Check this out!")


def a_closed_example():
# TODO Closed Issues are helpful! | This issue is closed, but the TODO string is still in the codebase!
print("This should be a red flag, because if the issue is still in the code then something isn't done yet")
print(
"This should be a red flag, because if the issue is still in the code then something isn't done yet"
)
print("(Though it may simply be that the comment hasn't been removed)")
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Example usage of # todoon
##########################


def an_unfinished_function():
# TODO Finish documenting todo-or-not
print("Hello, I'm not quite done, there's more to do!")
Expand All @@ -16,9 +17,7 @@ def a_broken_function():
# from the line that triggered the issue.
# The search for pertinent lines will stop when it hits a line break or the
# maximum number of lines, set by PERTINENT_LINE_LIMIT
a = [
1, 1, 2, 3
]
a = [1, 1, 2, 3]
b = sum(a)
c = b * len(a)
return c / 0 # FIXME I just don't know why this doesn't work!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ def a_broken_function():
# from the line that triggered the issue.
# The search for pertinent lines will stop when it hits a line break or the
# maximum number of lines, set by PERTINENT_LINE_LIMIT
a = [
1, 1, 2, 3
]
a = [1, 1, 2, 3]
b = sum(a)
c = b * len(a)
return c / 0 # FIXME I just don't know why this doesn't work!
Expand All @@ -30,5 +28,7 @@ def a_broken_function():

def a_closed_example():
# TODO Closed Issues are helpful! | This issue is closed, but the TODO string is still in the codebase!
print("This should be a red flag, because if the issue is still in the code then something isn't done yet")
print(
"This should be a red flag, because if the issue is still in the code then something isn't done yet"
)
print("(Though it may simply be that the comment hasn't been removed)")
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
def an_unfinished_function():
# TODO Finish documenting todo-or-not
void an_unfinished_function():
// TODO Finish documenting todo-or-not
print("Hello, I'm not quite done, there's more to do!")
print("Look at all these things I have to do!")
a = 1 + 1
b = a * 2
int a = 1 + 1
int b = a * 2
print("Okay I'm done!")


def a_closed_example():
# TODO Closed Issues are helpful! | This issue is closed, but the TODO string is still in the codebase!
void a_closed_example():
// TODO Closed Issues are helpful! | This issue is closed, but the TODO string is still in the codebase!
print("This should be a red flag, because if the issue is still in the code then something isn't done yet")
print("(Though it may simply be that the comment hasn't been removed)")
1 change: 1 addition & 0 deletions tests/resources/specific_files/r.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO R
1 change: 0 additions & 1 deletion tests/resources/specific_files/r.txt

This file was deleted.

2 changes: 1 addition & 1 deletion tests/resources/specific_files/s/t.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
TODO S/T
// TODO S/T
13 changes: 6 additions & 7 deletions tests/test_auxillary_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import unittest

import todo_or_not.todo_check
import todo_or_not.utility


class TestLocalization(unittest.TestCase):
Expand All @@ -11,27 +12,27 @@ def setUp(self):

def test_unsupported_and_supported_regions(self):
# Check unsupported
region = todo_or_not.todo_check.get_region()
region = todo_or_not.utility.get_region()

self.assertEqual(region, "en_us")

# Check supported
os.environ["REGION"] = "ko_kr"
region = todo_or_not.todo_check.get_region()
region = todo_or_not.utility.get_region()

self.assertEqual(region, "ko_kr")

os.environ["REGION"] = "en_us"

def test_unsupported_and_supported_operating_systems(self):
# Check unsupported
region = todo_or_not.todo_check.get_os()
region = todo_or_not.utility.get_os()

self.assertEqual(region, "default")

# Check supported
os.environ["OS"] = "windows_nt"
region = todo_or_not.todo_check.get_os()
region = todo_or_not.utility.get_os()

self.assertEqual(region, "windows_nt")

Expand All @@ -40,7 +41,5 @@ def test_get_encoding_file_not_exists():
assert todo_or_not.todo_check.get_encoding("!*&^#(#)@@", []) is None




if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
Loading

0 comments on commit 1f29665

Please sign in to comment.