Skip to content

Commit 1013517

Browse files
committed
Added check_outdated script (wip) that will check differences on documented and actual endpoints
1 parent ceb2fe4 commit 1013517

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ doc/
2525

2626
# Vagrant artifacts
2727
ubuntu-*-console.log
28+
29+
# Python
30+
__pycache__/

scripts/check_outdated.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import os
2+
import re
3+
4+
from settings import ENDPOINTS_DIR
5+
6+
DOCUMENTATION_DIR = os.path.join(os.path.dirname(__file__), "../source/includes")
7+
8+
def get_all_endpoints():
9+
endpoints = []
10+
for root, dirs, files in os.walk(ENDPOINTS_DIR):
11+
for file in files:
12+
with open(os.path.join(root, file), 'r') as f:
13+
if re.search(r"public bool \$api_disabled = true;", f.read()):
14+
continue
15+
16+
endpoints.append(root.split(ENDPOINTS_DIR)[1] + "/" + file[:-4])
17+
18+
return endpoints
19+
20+
def get_all_documented_endpoints():
21+
endpoints = []
22+
23+
for file in os.listdir(DOCUMENTATION_DIR):
24+
file_cat = file[1:-3]
25+
with open(os.path.join(DOCUMENTATION_DIR, file), 'r') as f:
26+
for line in f.readlines():
27+
match = re.match(r"curl https:\/\/api\.simplyprint\.io\/\{id\}(.*?)(\?| \\).*$", line)
28+
29+
if not match:
30+
continue
31+
32+
endpoints.append(match.group(1))
33+
34+
return endpoints
35+
36+
print(get_all_endpoints())
37+
print(get_all_documented_endpoints())
38+
39+
print()
40+
41+
print(set(get_all_endpoints()) ^ set(get_all_documented_endpoints()))

scripts/generate_markdown.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
import os
44
import re
5-
import json
5+
from settings import ENDPOINTS_DIR
66

7-
ENDPOINTS_DIR = "/home/dnorhoj/Documents/Work/Code/local-site-dev/api/Endpoints"
8-
#OUTPUT_DIR = "./_generated/"
9-
OUTPUT_DIR = "../source/includes/"
7+
OUTPUT_DIR = "./output"
108

119
# Template
1210
TEMPLATE = """

scripts/settings.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ENDPOINTS_DIR = "/home/dnorhoj/Documents/Work/Code/local-site-dev/api/Endpoints"

0 commit comments

Comments
 (0)