Legal documents are already a combination of data values and custom rules, they just also reference external rule sets such as legislation, regulation or case law. I work at a company where we use the same data points to generate the legal documents for a funding round as well as the cap table before and after the round is closed. Term sheets are just a very verbose data file lol.