if not os.path.isdir(os.path.join(get_isa_dir(), pth)):
log("warning, file not .mdwn, skipping", pth)
continue
- self.read_file(pth)
+ self.read_top_file(pth)
continue
# code which helped add in the keyword "Pseudo-code:" automatically
rewrite = self.read_file_for_rewrite(pth)
return rewrite
- def read_file(self, fname):
+ def read_top_file(self, fname):
pagename = fname.split('.')[0]
fname = os.path.join(get_isa_dir(), fname)
with open(fname) as f:
lines = f.readlines()
+ for lineno, line in enumerate(lines):
+ # look for HTML comment, if starting, skip line.
+ # XXX this is braindead! it doesn't look for the end
+ # so please put ending of comments on one line:
+ # <!-- line 1 comment -->
+ # <!-- line 2 comment -->
+ line = line.strip()
+ if line.startswith('<!--'):
+ continue
+ if line == "":
+ continue
+ re_match = re.fullmatch(
+ r'\[\[!inline pagenames="openpower/isa/([^" ]*[^"/ ])" '
+ r'raw="yes"]]', line)
+ assert re_match, (
+ f"{fname}:{lineno+1}: error: "
+ 'expected [[!inline]] directive, must be of the form:\n'
+ '[[!inline pagenames="openpower/isa/foo/bar" '
+ 'raw="yes"]]')
+ insn_fname = re_match[1] + ".mdwn"
+ insn_fname = os.path.join(get_isa_dir(), insn_fname)
+ self.read_file(pagename, insn_fname)
+
+ def read_file(self, pagename, fname):
+ with open(fname) as f:
+ lines = f.readlines()
+
# set up dict with current page name
d = {'page': pagename}