{"id":3607,"date":"2017-02-17T10:36:24","date_gmt":"2017-02-17T15:36:24","guid":{"rendered":"http:\/\/fgiasson.com\/blog\/?p=3607"},"modified":"2017-02-17T11:12:36","modified_gmt":"2017-02-17T16:12:36","slug":"literate-clojure-programming-publishing-documentation-in-multiple-formats","status":"publish","type":"post","link":"https:\/\/fgiasson.com\/blog\/index.php\/2017\/02\/17\/literate-clojure-programming-publishing-documentation-in-multiple-formats\/","title":{"rendered":"Literate [Clojure] Programming: Publishing Documentation In Multiple Formats"},"content":{"rendered":"<p>This blog post is the sixth, and the last, of a series of blog posts about Literate [Clojure] Programming in <a href=\"http:\/\/orgmode.org\/\">Org-mode<\/a> where I explain how I develop my [Clojure] applications using literate programming concepts and principles.<\/p>\n<p>This last post introduce a tool that leverage the side effect of having all the codes neatly discussed: it gives the possibility to automatically generate all different kinds of project documentation with a single key-binding. The documentation that we will generate are:<\/p>\n<ol class=\"org-ol\">\n<li>Human readable HTML general project documentation<\/li>\n<li>Programming API documentation<\/li>\n<li>Book style complete project documentation in PDF<\/li>\n<\/ol>\n<p>This series of blog posts about literate [Clojure] programming in Org-mode is composed of the following articles:<\/p>\n<ol class=\"org-ol\">\n<li><a href=\"https:\/\/fgiasson.com\/blog\/index.php\/2016\/06\/21\/optimal-emacs-settings-for-org-mode-for-literate-programming\/\">Configuring Emacs for Org-mode<\/a><\/li>\n<li><a href=\"https:\/\/fgiasson.com\/blog\/index.php\/2016\/07\/06\/literate-clojure-programming-using-org-mode\/\">Project folder structure<\/a><\/li>\n<li><a href=\"https:\/\/fgiasson.com\/blog\/index.php\/2016\/08\/11\/literate-clojure-programming-anatomy-of-a-org-mode-file\/\">Anatomy of a Org-mode file<\/a><\/li>\n<li><a href=\"https:\/\/fgiasson.com\/blog\/index.php\/2016\/10\/26\/literate-clojure-programming-tangle-all-in-org-mode\/\">Tangling all project files<\/a><\/li>\n<li><a href=\"https:\/\/fgiasson.com\/blog\/index.php\/2017\/02\/17\/literate-clojure-programming-publishing-documentation-in-multiple-formats\/\">Publishing documentation in multiple formats<\/a> (this post)<\/li>\n<li><a href=\"https:\/\/fgiasson.com\/blog\/index.php\/2016\/05\/30\/creating-and-running-unit-tests-directly-in-source-files-with-org-mode\/\">Unit Testing<\/a><\/li>\n<\/ol>\n<p><!--more--><\/p>\n<div id=\"outline-container-org666af11\" class=\"outline-2\">\n<h2 id=\"org666af11\">Documentation, Documentation, Documentation!<\/h2>\n<div id=\"text-org666af11\" class=\"outline-text-2\">\n<p>Not all documentation is equal and depending on what you are looking for, different kinds and different formats of documentation may work better depending on a task. If I want to read in depth the architecture of a project, if I want to understand the underlying assumptions and decisions that lead to a certain design, if I want to read text with figures about data structures I would prefer reading article like documentation in form of a HTML page or a PDF document.<\/p>\n<p>However, if I am programing something using a certain API, what I will be looking for is the documentation of the API with maybe some supporting material as required. I will be looking to understand how a specific function works, how its parameters are meant to be used, etc. I may also simply be looking for a consolidated list of available function calls. That kind of documentation is quite different than the previous one.<\/p>\n<p>The beauty of Literate Programming is that as a software developed, I don&#8217;t have to write each of these types of documentation independently. I have everything I need in my literate programming files (in this case, in my Org-mode files) to generate all kinds of different purposes documentation.<\/p>\n<p>Note that everything that is discussed in this series of blog posts has been applied to the <a href=\"https:\/\/github.com\/structureddynamics\/org-mode-clj-tests-utils\">org-mode-tests-utils<\/a> project. I would strongly suggest you to browse that project along with its folder structure to see how this works in a real [tiny] project.<\/p>\n<p>Now, let&#8217;s see how this can be accomplished.<\/p>\n<\/div>\n<\/div>\n<div id=\"outline-container-org52adaf4\" class=\"outline-2\">\n<h2 id=\"org52adaf4\">publish.org<\/h2>\n<div id=\"text-org52adaf4\" class=\"outline-text-2\">\n<p>What we want to do to generate all the different kinds of documentation is simply having to open a Org-mode file, and to click <code>C-c C-v t<\/code> which will run all the code blocks in the file that will generate all the documentation we want. That file is called <a href=\"https:\/\/github.com\/structureddynamics\/org-mode-clj-tests-utils\/blob\/master\/org\/publish.org\">publish.org<\/a> and is located in the <code>\/org\/<\/code> root folder.<\/p>\n<p>This file is split into three general sections:<\/p>\n<ol class=\"org-ol\">\n<li>Generate HTML Documentation<\/li>\n<li>Generate API Documentation<\/li>\n<li>Generate PDF Documentation<\/li>\n<\/ol>\n<p>Each of these sections contains the ELisp code blocks that are used to generate the different kind of documentation.<\/p>\n<\/div>\n<div id=\"outline-container-org1650bd7\" class=\"outline-3\">\n<h3 id=\"org1650bd7\">Generate HTML Documentation<\/h3>\n<div id=\"text-org1650bd7\" class=\"outline-text-3\">\n<p>What the HTML documentation generator does is to search and find [recursively] all the <code>.org<\/code> files that exists in the <code>\/org\/<\/code> folder of your project. Then it will generate a <code>sitemap.org<\/code> file if it is not already existing that it will use to generate the HTML documentation.<\/p>\n<\/div>\n<div id=\"outline-container-org13cfee3\" class=\"outline-4\">\n<h4 id=\"org13cfee3\">Themes<\/h4>\n<div id=\"text-org13cfee3\" class=\"outline-text-4\">\n<p>Different themes and styles can be defined for the generated HTML pages. To enable a theme, you simply have to select the proper <code>:html-head<\/code> setting.<\/p>\n<p>The main themes come from the <a href=\"https:\/\/github.com\/fniessen\/org-html-themes\">org-html-themes<\/a> extension. The theme currently being used is called <code>readtheorg<\/code>.<\/p>\n<\/div>\n<\/div>\n<div id=\"outline-container-org4ee5843\" class=\"outline-4\">\n<h4 id=\"org4ee5843\">Publishing Options<\/h4>\n<div id=\"text-org4ee5843\" class=\"outline-text-4\">\n<p>A series of settings can be configured to create the documentation the way you want. Here are the main settings:<\/p>\n<ul class=\"org-ul\">\n<li>Settings\n<ul class=\"org-ul\">\n<li><code>:base-directory<\/code>\n<ul class=\"org-ul\">\n<li>The base directory is the current directory which is the <code>[project]\/org\/<\/code> directory where all the Org files are defined<\/li>\n<\/ul>\n<\/li>\n<li><code>:recursive<\/code>\n<ul class=\"org-ul\">\n<li>We specify that we want Org-mode to generate HTML files for each Org file in all children folder (recursively)<\/li>\n<\/ul>\n<\/li>\n<li><code>:publishing-directory<\/code>\n<ul class=\"org-ul\">\n<li>We specify where we want to publish the HTML documentation from the Org files<\/li>\n<\/ul>\n<\/li>\n<li><code>:publishing-function<\/code>\n<ul class=\"org-ul\">\n<li>We specify that we want to publish everything in HTML<\/li>\n<\/ul>\n<\/li>\n<li><code>:section-numbers<\/code>\n<ul class=\"org-ul\">\n<li>We don&#8217;t want any kind of section numbers generated by Org-mode<\/li>\n<\/ul>\n<\/li>\n<li><code>:with-toc<\/code>\n<ul class=\"org-ul\">\n<li>We want to include a table of content for each generated documentation file<\/li>\n<\/ul>\n<\/li>\n<li><code>:auto-sitemap<\/code>\n<ul class=\"org-ul\">\n<li>We want to generate a sitemap automatically. The file is named <code>sitemap.html<\/code><\/li>\n<\/ul>\n<\/li>\n<li><code>:html-head<\/code>\n<ul class=\"org-ul\">\n<li>We want to specify a style sheet that will be used by each generated HTML file. It should be located in <code>doc\/html\/css\/<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Additional settings and configurations are available from these two web pages:<\/p>\n<ul class=\"org-ul\">\n<li><a href=\"http:\/\/orgmode.org\/manual\/Publishing.html#Publishing\">Org-mode Publishing<\/a><\/li>\n<li><a href=\"http:\/\/orgmode.org\/worg\/org-8.0.html#sec-5\">Org-mode 8 &amp; 9 Updates<\/a><\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div id=\"outline-container-org25fb755\" class=\"outline-4\">\n<h4 id=\"org25fb755\">Publish<\/h4>\n<div id=\"text-org25fb755\" class=\"outline-text-4\">\n<p>To publish in HTML, you simply have to run the following code blocks:<\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-emacs-lisp\"><span style=\"color: #ae81ff;\">(<\/span><span style=\"color: #f92672;\">defun<\/span> <span style=\"color: #a6e22e;\">org-publish-org-sitemap-includes<\/span> <span style=\"color: #66d9ef;\">(<\/span>project <span style=\"color: #66d9ef;\">&amp;optional<\/span> sitemap-filename<span style=\"color: #66d9ef;\">)<\/span>\n  <span style=\"color: #75715e;\">\"Create a sitemap of pages in set defined by PROJECT.<\/span>\n<span style=\"color: #75715e;\">Optionally set the filename of the sitemap with SITEMAP-FILENAME.<\/span>\n<span style=\"color: #75715e;\">Default for SITEMAP-FILENAME is `<\/span><span style=\"color: #ae81ff;\">sitemap.org<\/span><span style=\"color: #75715e;\">'.\"<\/span>\n  <span style=\"color: #66d9ef;\">(<\/span><span style=\"color: #f92672;\">let*<\/span> <span style=\"color: #a6e22e;\">(<\/span><span style=\"color: #e6db74;\">(<\/span>project-plist <span style=\"color: #fd971f;\">(<\/span>cdr project<span style=\"color: #fd971f;\">)<\/span><span style=\"color: #e6db74;\">)<\/span>\n         <span style=\"color: #e6db74;\">(<\/span>dir <span style=\"color: #fd971f;\">(<\/span>file-name-as-directory\n               <span style=\"color: #f92672;\">(<\/span>plist-get project-plist <span style=\"color: #f92672;\">:base-directory<\/span><span style=\"color: #f92672;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #e6db74;\">)<\/span>\n         <span style=\"color: #e6db74;\">(<\/span>localdir <span style=\"color: #fd971f;\">(<\/span>file-name-directory dir<span style=\"color: #fd971f;\">)<\/span><span style=\"color: #e6db74;\">)<\/span>\n         <span style=\"color: #e6db74;\">(<\/span>exclude-regexp <span style=\"color: #fd971f;\">(<\/span>plist-get project-plist <span style=\"color: #f92672;\">:exclude<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #e6db74;\">)<\/span>\n         <span style=\"color: #e6db74;\">(<\/span>files <span style=\"color: #fd971f;\">(<\/span>nreverse\n                 <span style=\"color: #f92672;\">(<\/span>org-publish-get-base-files project exclude-regexp<span style=\"color: #f92672;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #e6db74;\">)<\/span>\n         <span style=\"color: #e6db74;\">(<\/span>sitemap-filename <span style=\"color: #fd971f;\">(<\/span>concat dir <span style=\"color: #f92672;\">(<\/span><span style=\"color: #f92672;\">or<\/span> sitemap-filename <span style=\"color: #e6db74;\">\"sitemap.org\"<\/span><span style=\"color: #f92672;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #e6db74;\">)<\/span>\n         <span style=\"color: #e6db74;\">(<\/span>sitemap-title <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #f92672;\">or<\/span> <span style=\"color: #f92672;\">(<\/span>plist-get project-plist <span style=\"color: #f92672;\">:sitemap-title<\/span><span style=\"color: #f92672;\">)<\/span>\n                            <span style=\"color: #f92672;\">(<\/span>concat <span style=\"color: #e6db74;\">\"Sitemap for project \"<\/span> <span style=\"color: #ae81ff;\">(<\/span>car project<span style=\"color: #ae81ff;\">)<\/span><span style=\"color: #f92672;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #e6db74;\">)<\/span>\n         <span style=\"color: #e6db74;\">(<\/span>sitemap-sans-extension\n          <span style=\"color: #fd971f;\">(<\/span>plist-get project-plist <span style=\"color: #f92672;\">:sitemap-sans-extension<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #e6db74;\">)<\/span>\n         <span style=\"color: #e6db74;\">(<\/span>visiting <span style=\"color: #fd971f;\">(<\/span>find-buffer-visiting sitemap-filename<span style=\"color: #fd971f;\">)<\/span><span style=\"color: #e6db74;\">)<\/span>\n         file sitemap-buffer<span style=\"color: #a6e22e;\">)<\/span>\n    <span style=\"color: #a6e22e;\">(<\/span><span style=\"color: #f92672;\">with-current-buffer<\/span>\n        <span style=\"color: #e6db74;\">(<\/span><span style=\"color: #f92672;\">let<\/span> <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #f92672;\">(<\/span>org-inhibit-startup t<span style=\"color: #f92672;\">)<\/span><span style=\"color: #fd971f;\">)<\/span>\n          <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #f92672;\">setq<\/span> sitemap-buffer\n                <span style=\"color: #f92672;\">(<\/span><span style=\"color: #f92672;\">or<\/span> visiting <span style=\"color: #ae81ff;\">(<\/span>find-file sitemap-filename<span style=\"color: #ae81ff;\">)<\/span><span style=\"color: #f92672;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #e6db74;\">)<\/span>\n      <span style=\"color: #e6db74;\">(<\/span>erase-buffer<span style=\"color: #e6db74;\">)<\/span>\n      <span style=\"color: #e6db74;\">(<\/span>insert <span style=\"color: #fd971f;\">(<\/span>concat <span style=\"color: #e6db74;\">\"#+TITLE: \"<\/span> sitemap-title <span style=\"color: #e6db74;\">\"\\n\\n\"<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #e6db74;\">)<\/span>\n      <span style=\"color: #e6db74;\">(<\/span><span style=\"color: #f92672;\">while<\/span> <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #f92672;\">setq<\/span> file <span style=\"color: #f92672;\">(<\/span><span style=\"color: #f92672;\">pop<\/span> files<span style=\"color: #f92672;\">)<\/span><span style=\"color: #fd971f;\">)<\/span>\n        <span style=\"color: #fd971f;\">(<\/span><span style=\"color: #f92672;\">let<\/span> <span style=\"color: #f92672;\">(<\/span><span style=\"color: #ae81ff;\">(<\/span>link <span style=\"color: #66d9ef;\">(<\/span>file-relative-name file dir<span style=\"color: #66d9ef;\">)<\/span><span style=\"color: #ae81ff;\">)<\/span>\n              <span style=\"color: #ae81ff;\">(<\/span>oldlocal localdir<span style=\"color: #ae81ff;\">)<\/span><span style=\"color: #f92672;\">)<\/span>\n          <span style=\"color: #f92672;\">(<\/span><span style=\"color: #f92672;\">when<\/span> sitemap-sans-extension\n            <span style=\"color: #ae81ff;\">(<\/span><span style=\"color: #f92672;\">setq<\/span> link <span style=\"color: #66d9ef;\">(<\/span>file-name-sans-extension link<span style=\"color: #66d9ef;\">)<\/span><span style=\"color: #ae81ff;\">)<\/span><span style=\"color: #f92672;\">)<\/span>\n          <span style=\"color: #75715e; font-style: italic;\">;; <\/span><span style=\"color: #75715e; font-style: italic;\">sitemap shouldn't list itself<\/span>\n          <span style=\"color: #f92672;\">(<\/span><span style=\"color: #f92672;\">unless<\/span> <span style=\"color: #ae81ff;\">(<\/span>equal <span style=\"color: #66d9ef;\">(<\/span>file-truename sitemap-filename<span style=\"color: #66d9ef;\">)<\/span>\n                         <span style=\"color: #66d9ef;\">(<\/span>file-truename file<span style=\"color: #66d9ef;\">)<\/span><span style=\"color: #ae81ff;\">)<\/span>     \n            <span style=\"color: #ae81ff;\">(<\/span><span style=\"color: #f92672;\">let<\/span> <span style=\"color: #66d9ef;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span>entry\n                   <span style=\"color: #ae81ff;\">(<\/span>org-publish-format-file-entry\n                    org-publish-sitemap-file-entry-format file project-plist<span style=\"color: #ae81ff;\">)<\/span><span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span>\n              <span style=\"color: #66d9ef;\">(<\/span>insert <span style=\"color: #a6e22e;\">(<\/span>concat <span style=\"color: #e6db74;\">\"* \"<\/span> entry <span style=\"color: #e6db74;\">\"\\n\"<\/span>\n                              <span style=\"color: #e6db74;\">\"#+INCLUDE: \"<\/span> link <span style=\"color: #e6db74;\">\"\\n\"<\/span><span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span><span style=\"color: #ae81ff;\">)<\/span><span style=\"color: #f92672;\">)<\/span><span style=\"color: #fd971f;\">)<\/span><span style=\"color: #e6db74;\">)<\/span>\n      <span style=\"color: #e6db74;\">(<\/span>save-buffer<span style=\"color: #e6db74;\">)<\/span><span style=\"color: #a6e22e;\">)<\/span>\n    <span style=\"color: #a6e22e;\">(<\/span><span style=\"color: #f92672;\">or<\/span> visiting <span style=\"color: #e6db74;\">(<\/span>kill-buffer sitemap-buffer<span style=\"color: #e6db74;\">)<\/span><span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span><span style=\"color: #ae81ff;\">)<\/span>\n<\/pre>\n<\/div>\n<div class=\"org-src-container\">\n<pre class=\"src src-emacs-lisp\"><span style=\"color: #ae81ff;\">(<\/span><span style=\"color: #f92672;\">setq<\/span> org-publish-project-alist\n      '<span style=\"color: #66d9ef;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span><span style=\"color: #e6db74;\">\"org-mode-clj-tests-utils--doc-html\"<\/span>\n         <span style=\"color: #f92672;\">:base-directory<\/span> <span style=\"color: #e6db74;\">\".\"<\/span>\n         <span style=\"color: #f92672;\">:publishing-directory<\/span> <span style=\"color: #e6db74;\">\"..\/doc\/html\"<\/span>\n         <span style=\"color: #f92672;\">:publishing-function<\/span> org-html-publish-to-html\n         <span style=\"color: #f92672;\">:section-numbers<\/span> nil\n         <span style=\"color: #f92672;\">:recursive<\/span> t\n         <span style=\"color: #f92672;\">:exclude<\/span> <span style=\"color: #e6db74;\">\"fulldoc\\\\.org<\/span><span style=\"color: #ae81ff;\">\\\\<\/span><span style=\"color: #e6db74;\">|<\/span><span style=\"color: #e6db74;\">project\\\\.org<\/span><span style=\"color: #ae81ff;\">\\\\<\/span><span style=\"color: #e6db74;\">|<\/span><span style=\"color: #e6db74;\">tangle\\\\-all\\\\.org<\/span><span style=\"color: #ae81ff;\">\\\\<\/span><span style=\"color: #e6db74;\">|<\/span><span style=\"color: #e6db74;\">setup\\\\.org<\/span><span style=\"color: #ae81ff;\">\\\\<\/span><span style=\"color: #e6db74;\">|<\/span><span style=\"color: #e6db74;\">publish\\\\.org\"<\/span>\n         <span style=\"color: #f92672;\">:with-toc<\/span> t\n         <span style=\"color: #f92672;\">:auto-sitemap<\/span> t\n         <span style=\"color: #f92672;\">:sitemap-function<\/span> org-publish-org-sitemap-includes\n\n                                        <span style=\"color: #75715e; font-style: italic;\">; <\/span><span style=\"color: #75715e; font-style: italic;\">ReadTheOrg Theme<\/span>\n         <span style=\"color: #f92672;\">:html-head<\/span> <span style=\"color: #e6db74;\">\"&lt;link rel=\\\"stylesheet\\\" type=\\\"text\/css\\\" href=\\\"themes\/styles\/readtheorg\/css\/htmlize.css\\\"\/&gt;<\/span>\n<span style=\"color: #e6db74;\">&lt;link rel=\\\"stylesheet\\\" type=\\\"text\/css\\\" href=\\\"themes\/styles\/readtheorg\/css\/readtheorg.css\\\"\/&gt;<\/span>\n<span style=\"color: #e6db74;\">&lt;script src=\\\"https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/2.1.3\/jquery.min.js\\\"&gt;&lt;\/script&gt;<\/span>\n<span style=\"color: #e6db74;\">&lt;script src=\\\"https:\/\/maxcdn.bootstrapcdn.com\/bootstrap\/3.3.4\/js\/bootstrap.min.js\\\"&gt;&lt;\/script&gt;<\/span>\n<span style=\"color: #e6db74;\">&lt;script type=\\\"text\/javascript\\\" src=\\\"themes\/styles\/lib\/js\/jquery.stickytableheaders.js\\\"&gt;&lt;\/script&gt;<\/span>\n<span style=\"color: #e6db74;\">&lt;script type=\\\"text\/javascript\\\" src=\\\"themes\/styles\/readtheorg\/js\/readtheorg.js\\\"&gt;&lt;\/script&gt;\"<\/span><span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span><span style=\"color: #ae81ff;\">)<\/span>\n<\/pre>\n<\/div>\n<div class=\"org-src-container\">\n<pre class=\"src src-emacs-lisp\"><span style=\"color: #ae81ff;\">(<\/span><span style=\"color: #f92672;\">setq<\/span> org-publish-use-timestamps-flag nil<span style=\"color: #ae81ff;\">)<\/span>\n<\/pre>\n<\/div>\n<div class=\"org-src-container\">\n<pre class=\"src src-emacs-lisp\"><span style=\"color: #ae81ff;\">(<\/span><span style=\"color: #f92672;\">setq<\/span> org-export-html-style-include-scripts nil\n      org-export-html-style-include-default nil<span style=\"color: #ae81ff;\">)<\/span>\n\n<span style=\"color: #ae81ff;\">(<\/span>org-publish-all<span style=\"color: #ae81ff;\">)<\/span>\n<\/pre>\n<\/div>\n<p>Once everything is properly configured, <code>(org-publish-all)<\/code> is run and the HTML documentation get generated in the <code>\/doc\/html\/<\/code> folder. You can see what the generated HTML documentation looks like <a href=\"https:\/\/github.com\/structureddynamics\/org-mode-clj-tests-utils\/tree\/master\/doc\/html\">here<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"outline-container-orgcb2a3ba\" class=\"outline-3\">\n<h3 id=\"orgcb2a3ba\">Generate API Documentation<\/h3>\n<div id=\"text-orgcb2a3ba\" class=\"outline-text-3\">\n<p>Programming API documentation is also easy to generate. In this case, what we are doing is to use the tangled code to generate the API documentation. Here we are using Clojure&#8217;s <a href=\"https:\/\/github.com\/weavejester\/codox\">Codox<\/a> API code generator to generate the documentation, but we could have used any other such libraries to do the same.<\/p>\n<p>To generate the API documentation, we simply have to run this Clojure code block and use Codox&#8217;s API to generate the full documentation.<\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-clojure\"><span style=\"color: #ae81ff;\">(<\/span>use '<span style=\"color: #66d9ef;\">codox.main<\/span><span style=\"color: #ae81ff;\">)<\/span>\n\n<span style=\"color: #ae81ff;\">(<\/span>generate-docs <span style=\"color: #66d9ef;\">{<\/span><span style=\"color: #ae81ff;\">:output-path<\/span> <span style=\"color: #e6db74;\">\"doc\/api\"<\/span><span style=\"color: #66d9ef;\">}<\/span><span style=\"color: #ae81ff;\">)<\/span>\n<\/pre>\n<\/div>\n<p>The generated documentation will appear in the <code>\/doc\/api\/<\/code> folder. You can see what the generated API documentation looks like <a href=\"https:\/\/github.com\/structureddynamics\/org-mode-clj-tests-utils\/tree\/master\/doc\/api\">here<\/a>.<\/p>\n<\/div>\n<\/div>\n<div id=\"outline-container-org51ae423\" class=\"outline-3\">\n<h3 id=\"org51ae423\">Generate PDF Documentation<\/h3>\n<div id=\"text-org51ae423\" class=\"outline-text-3\">\n<p>Finally, we can leverage Org-mode&#8217;s internal <code>(org-publish-current-project)<\/code> internal function to generate a PDF version of each Org-mode file within the <code>\/org\/<\/code> folder (recursively). We leverage the <code>org-latex-publish-to-pdf<\/code> publishing function to generate the files in PDF.<\/p>\n<div class=\"org-src-container\">\n<pre class=\"src src-emacs-lisp\"><span style=\"color: #ae81ff;\">(<\/span><span style=\"color: #f92672;\">setq<\/span> org-publish-project-alist\n      '<span style=\"color: #66d9ef;\">(<\/span><span style=\"color: #a6e22e;\">(<\/span><span style=\"color: #e6db74;\">\"org-mode-clj-tests-utils--doc-pdf\"<\/span>\n         <span style=\"color: #f92672;\">:base-directory<\/span> <span style=\"color: #e6db74;\">\".\"<\/span>\n         <span style=\"color: #f92672;\">:publishing-directory<\/span> <span style=\"color: #e6db74;\">\"..\/doc\/pdf\"<\/span>\n         <span style=\"color: #f92672;\">:publishing-function<\/span> org-latex-publish-to-pdf\n         <span style=\"color: #f92672;\">:recursive<\/span> t\n         <span style=\"color: #f92672;\">:section-numbers<\/span> nil\n         <span style=\"color: #f92672;\">:with-toc<\/span> t\n         <span style=\"color: #f92672;\">:auto-sitemap<\/span> t<span style=\"color: #a6e22e;\">)<\/span><span style=\"color: #66d9ef;\">)<\/span><span style=\"color: #ae81ff;\">)<\/span>\n<\/pre>\n<\/div>\n<div class=\"org-src-container\">\n<pre class=\"src src-emacs-lisp\"><span style=\"color: #ae81ff;\">(<\/span>org-publish-current-project<span style=\"color: #ae81ff;\">)<\/span>\n<\/pre>\n<\/div>\n<p>The generated PDF documentation will appear in the <code>\/doc\/pdf\/<\/code> folder. You can see what the generated API documentation looks like <a href=\"https:\/\/github.com\/structureddynamics\/org-mode-clj-tests-utils\/tree\/master\/doc\/pdf\">here<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"outline-container-orgb517b0c\" class=\"outline-2\">\n<h2 id=\"orgb517b0c\">Conclusion<\/h2>\n<div id=\"text-orgb517b0c\" class=\"outline-text-2\">\n<p>This is what conclude my series of six blog posts about how I do Literate Programming [in Clojure using Org-mode]. As I mentioned in another article, the problem of writing readable code which is well commented, well documented and well tested is that ideally we would have to focus on all these aspects at the same time, but given the development environments used by most people, it is not possible. You will plan an aspect of your program and write the code. Then if you are really lucky and you will find (or take) the time to write some documentation and create some unit tests. The problem is that each of these tasks are siloed: they are performed in isolation with 4 different states of minds, at 4 different times and hopefully within 4 weeks. The worse happens when you start fixing bugs or improving the code: comments, documentation and unit tests will often remain unchanged and lagging behind.<\/p>\n<p>This is what Literate Programming is for me: a way to perform all these tasks at once, with the same state of mind, at the same time. This is a process to put in place, a new way to work. The problem is to put in place that process, that way to work, that enables you do to all this at once. I hope I have been able to put in place and explains a Literate Programming process that can work for you and shows the benefits of doing so.<\/p>\n<p>I have the feeling that it will become more and more important to write readable code and to write about the thought process that lead to that written code. Much of the code we are writing in these days is code that manipulates and transform data, code that implement machine learning workflows and such. The kind of code that greatly benefit to be readable by many people other than the ones that write the code.<\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Last post of a series of posts about literate programming that introduce a tool that leverage the side effect of having all the codes neatly discussed: it gives the possibility to automatically generate all different kinds of project documentation with a single key-binding.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[251,279,277,66],"tags":[252,274,276],"class_list":["post-3607","post","type-post","status-publish","format-standard","hentry","category-clojure","category-emacs","category-literate-programming","category-programming","tag-clojure-2","tag-literateprogramming","tag-orgmode"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3607","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=3607"}],"version-history":[{"count":8,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3607\/revisions"}],"predecessor-version":[{"id":3623,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/3607\/revisions\/3623"}],"wp:attachment":[{"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=3607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=3607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fgiasson.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=3607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}