Look at Thesisdown[0] which is a modified bookdown[1] template for a thesis. It’s based on R Markdown[2], so you get R (or other programming languages) in your document that is run when the document is processed.
The authors of R Markdown/Bookdown are working on a newer tool, Quarto[3].
[0] https://github.com/ismayc/thesisdown [1] https://bookdown.org/ [2] https://rmarkdown.rstudio.com/ [3] https://quarto.org/