mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
Organized readme and added imports to some generators
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from mathgenerator.mathgen import *
|
||||
|
||||
write_list = []
|
||||
|
||||
def array2markdown_table(string):
|
||||
string = string.replace("[[", "<table><tr><td>")
|
||||
@@ -12,13 +13,7 @@ def array2markdown_table(string):
|
||||
return string
|
||||
|
||||
|
||||
wList = getGenList()
|
||||
lines = []
|
||||
with open('mathgenerator/mathgen.py', 'r') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
allRows = []
|
||||
for item in wList:
|
||||
def write_row(item):
|
||||
myGen = item[2]
|
||||
# NOTE: renamed 'sol' to 'solu' to make it look nicer
|
||||
prob, solu = myGen()
|
||||
@@ -35,8 +30,44 @@ for item in wList:
|
||||
# NOTE: renamed 'def_name' to 'func_name' because it suits it more
|
||||
func_name = item[3]
|
||||
row = [myGen.id, myGen.title, prob, solu, func_name]
|
||||
tableLine = "| " + str(row[0]) + " | " + str(row[1]) + " | " + str(
|
||||
row[2]) + " | " + str(row[3]) + " | " + str(row[4]) + " |\n"
|
||||
print('added', item[1], '-', func_name, 'to the README.md')
|
||||
allRows.append(row)
|
||||
return tableLine
|
||||
|
||||
def make_table_header(name):
|
||||
lines = [
|
||||
'## ' + name + '\n',
|
||||
'| Id | Skill | Example problem | Example Solution | Function Name |\n',
|
||||
'|------|-------|-----------------|------------------|---------------|\n'
|
||||
]
|
||||
for line in lines:
|
||||
write_list.append(line)
|
||||
|
||||
def write_subject_table(subject_name, full_gen_list):
|
||||
subject_list = []
|
||||
# Create list of generators in given subject
|
||||
for gen in full_gen_list:
|
||||
if gen[4] == subject_name:
|
||||
subject_list.append(gen)
|
||||
subject_list.sort()
|
||||
|
||||
# Create table header
|
||||
make_table_header(subject_name)
|
||||
|
||||
# Add each item to write_list
|
||||
for item in subject_list:
|
||||
write_list.append(write_row(item))
|
||||
|
||||
|
||||
wList = getGenList()
|
||||
lines = []
|
||||
with open('mathgenerator/mathgen.py', 'r') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
subjects = ['algebra', 'basic_math', 'calculus', 'computer_science', 'geometry', 'misc', 'statistics']
|
||||
for subject in subjects:
|
||||
write_subject_table(subject, wList)
|
||||
|
||||
with open('README.md', "r") as g:
|
||||
lines = g.readlines()
|
||||
@@ -44,10 +75,8 @@ with open('README.md', "r") as g:
|
||||
line = lines.index('|------|-------|-----------------|------------------|---------------|\n')
|
||||
lines = lines[:line + 1]
|
||||
|
||||
for row in allRows:
|
||||
tableLine = "| " + str(row[0]) + " | " + str(row[1]) + " | " + str(
|
||||
row[2]) + " | " + str(row[3]) + " | " + str(row[4]) + " |\n"
|
||||
lines.append(tableLine)
|
||||
for write_line in write_list:
|
||||
lines.append(write_line)
|
||||
|
||||
with open('README.md', "w") as g:
|
||||
g.writelines(lines)
|
||||
|
||||
Reference in New Issue
Block a user