1# This script combines FIRLangRef_Header.md with the auto-generated Dialect/FIRLangRef.md 2# for the purpose of creating an introduction header/paragraph for FIRLangRef.html. 3 4import os 5 6# These paths are relative to flang/docs in the build directory, not source, as that's where this tool is executed. 7HEADER_PATH = os.path.join('Source', 'FIR', 'FIRLangRef_Header.md') 8DOCS_PATH = os.path.join('Dialect', 'FIRLangRef.md') 9OUTPUT_PATH = os.path.join('Source', 'FIRLangRef.md') 10 11# 1. Writes line 1 from docs to output, (comment line that the file is autogenerated) 12# 2. Adds a new line 13# 3. Writes the entire header to the output file 14# 4. Writes the remainder of docs to the output file 15with open(OUTPUT_PATH, 'w') as output: 16 with open(HEADER_PATH, 'r') as header, open(DOCS_PATH, 'r') as docs: 17 output.write(docs.readline()) 18 output.write("\n") 19 output.write(header.read()) 20 output.write(docs.read()) 21