Tidy?
This commit is contained in:
+456
-1351
File diff suppressed because one or more lines are too long
+621
-2047
File diff suppressed because one or more lines are too long
@@ -1,6 +1,8 @@
|
|||||||
|
import xml.etree.ElementTree as ET
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import hashlib, re, sys
|
import hashlib, re, sys
|
||||||
sys.path.append('../../implementations/Python')
|
sys.path.append('../../implementations/Python')
|
||||||
|
import markdown
|
||||||
import joy
|
import joy
|
||||||
from myhtml import HTML
|
from myhtml import HTML
|
||||||
|
|
||||||
@@ -64,6 +66,23 @@ def def_format(to, name):
|
|||||||
to += end
|
to += end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def foo(to, text):
|
||||||
|
html = markdown.markdown(text, output_format="html5")
|
||||||
|
html = '<div class="notes">' + html + '</div>'
|
||||||
|
try:
|
||||||
|
t = ET.fromstringlist([html])
|
||||||
|
except:
|
||||||
|
print(repr(html))
|
||||||
|
raise
|
||||||
|
to += t
|
||||||
|
|
||||||
|
|
||||||
|
basis_functions = set('''\
|
||||||
|
i dip branch loop
|
||||||
|
cons first rest stack swaack
|
||||||
|
dup swap pop clear'''.split())
|
||||||
|
|
||||||
k = re.split('^-+$', md, flags=re.MULTILINE)
|
k = re.split('^-+$', md, flags=re.MULTILINE)
|
||||||
#k = md.split('------------------------------------------------------------------------\n')
|
#k = md.split('------------------------------------------------------------------------\n')
|
||||||
del k[0]
|
del k[0]
|
||||||
@@ -78,7 +97,7 @@ k = [section.splitlines() for section in k]
|
|||||||
##assert not s # one header per section
|
##assert not s # one header per section
|
||||||
|
|
||||||
def anchor_for(name):
|
def anchor_for(name):
|
||||||
return 'function_' + (
|
return (
|
||||||
name
|
name
|
||||||
if name.isalpha()
|
if name.isalpha()
|
||||||
else hashlib.sha256(name.encode()).hexdigest()
|
else hashlib.sha256(name.encode()).hexdigest()
|
||||||
@@ -103,8 +122,6 @@ combinators = set(
|
|||||||
for name in combinators:
|
for name in combinators:
|
||||||
sections[name].remove('Combinator')
|
sections[name].remove('Combinator')
|
||||||
|
|
||||||
# Crosslinks
|
|
||||||
|
|
||||||
crosslinks = {}
|
crosslinks = {}
|
||||||
for name, section in sections.items():
|
for name, section in sections.items():
|
||||||
try:
|
try:
|
||||||
@@ -200,9 +217,15 @@ with doc.body as b:
|
|||||||
title = d.h2(name, id=anchor_id, class_='func_name')
|
title = d.h2(name, id=anchor_id, class_='func_name')
|
||||||
title += ' '
|
title += ' '
|
||||||
title.a('¶', href='#' + anchor_id, class_='self_link')
|
title.a('¶', href='#' + anchor_id, class_='self_link')
|
||||||
|
with d.p as tags:
|
||||||
if name in combinators:
|
if name in combinators:
|
||||||
d.p.span('combinator', class_='kind')
|
tags.span('combinator', class_='kind')
|
||||||
d.pre('\n'.join(section))
|
tags += ' '
|
||||||
|
if name in basis_functions:
|
||||||
|
tags.span('built-in', class_='kind')
|
||||||
|
|
||||||
|
foo(d, '\n'.join(section))
|
||||||
|
|
||||||
def_format(d, name)
|
def_format(d, name)
|
||||||
add_discussion(d, name)
|
add_discussion(d, name)
|
||||||
add_crosslinks(d, name)
|
add_crosslinks(d, name)
|
||||||
|
|||||||
Reference in New Issue
Block a user