1

Building .html files from .md files for a web site, I have some .md files which should not produce an output .html (e.g. because not ready for publication). What is the best way to achieve this with shake?

I have a want for html files and a rule which searches the corresponding .md file, but some do not produce the .html and shake stops with the error Error, rule finished running but did not produce file:.

What is the best way to deal with this case?

user855443
  • 2,596
  • 3
  • 25
  • 37

1 Answers1

2

The current restriction is that every file must produce a result. Some other build systems are slightly more lax about that, but my experience is it's nearly always a source of bugs - although in some cases it is useful (e.g. yours). The options are:

  • If you can easily detect that a file doesn't require an output creating for it you can do that before the want - namely by turning the want into an action that calls need, but only on a subset of the outputs.
  • If detecting you don't need to create anything is expensive you can have a rule that always produces a file, but sometimes produces an empty file, and then a separate rule that depends on that file and copies over only the ones with content.

Unfortunately, neither of these situations is ideal. At one point Shake had the option to make failure to create a file a valid result, which could be reintroduced if there was sufficient demand.

Neil Mitchell
  • 9,090
  • 1
  • 27
  • 85
  • I was expecting somewhere a flag or a relaxed command to allow a rule to not produce a file. Would this be difficult to add? I think to produce empty files is sort of messy, but will be possible. -- I understand that shake stores the inputs and it seems possible to get at it; I think I saw some documentation, but cannot find it again. Where is it? – user855443 Apr 03 '19 at 08:36
  • I re-read your original academic paper and understand now what data you store. I expected some general cache mechanism, but this should be a different package. – user855443 Apr 03 '19 at 17:41
  • I think not requiring creation of the file is feasible, it's just a case of how you expose it as an API. I suggest you create a ticket at https://github.com/ndmitchell/shake/issues and we discuss it there. – Neil Mitchell Apr 26 '19 at 13:01
  • I currently retructure the code and apply `shake` to a related similar application and hope to learn more about how to use `shake`. I will start an issue when I have gained a clearer view what is needed and what the limits are. – user855443 Apr 26 '19 at 13:05