gpoore / codebraid

Live code in Pandoc Markdown
BSD 3-Clause "New" or "Revised" License
367 stars 13 forks source link

Proposal for adding developer oriented Makefile example #29

Open staticaland opened 4 years ago

staticaland commented 4 years ago

My dream is to use codebraid to write README.md files for all my projects.

To achieve this I have come up with a Makefile to convert all .cbmd files in a repository. This makes it much easier to get up and running with a more automated workflow. I feel it is a must to convince all my programmer friends that using Codebraid for this purpose is awesome. I would love to see literate programming reach a wider audience.

I have been exploring the possibilites in this repo if you are curious.

Would you be interested in a PR with an example for this workflow? Perhaps as a subfolder in the examples directory.

Makefile:

CODEBRAID_DOCS := $(shell find . -name '*.cbmd')
MARKDOWN_DOCS = $(CODEBRAID_DOCS:.cbmd=.md)

.PHONY: cbmd watch

# Must cd into the target file directory so Pandoc and Codebraid are
# able to use relative paths as one would expect
%.md : %.cbmd
    cd $(@D); codebraid pandoc --from markdown --to gfm --filter=mermaid-filter --output $(notdir $@) --overwrite $(notdir $^)

cbmd : $(MARKDOWN_DOCS)

watch :
    find . -name '*.cbmd' | entr make cbmd