summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2023-05-28 15:27:12 +0100
committerYann Herklotz <git@yannherklotz.com>2023-05-28 15:27:12 +0100
commitd29b8cef5a13c8d351b0c8d6f88583941f404aa8 (patch)
tree0b39b35fed1f562dec34ca4e333ed0b185c2cf75 /src
parenteea7483f30bf67b59b5df0f2823b831d26936aa4 (diff)
downloadzk-visual-d29b8cef5a13c8d351b0c8d6f88583941f404aa8.tar.gz
zk-visual-d29b8cef5a13c8d351b0c8d6f88583941f404aa8.zip
Add documentation to all files
Diffstat (limited to 'src')
-rw-r--r--src/Main.hs8
-rw-r--r--src/Zettel.hs8
-rw-r--r--src/Zettel/Bibliography.hs34
-rw-r--r--src/Zettel/Common.hs8
-rw-r--r--src/Zettel/Links.hs8
-rw-r--r--src/Zettel/Math.hs8
-rw-r--r--src/Zettel/Parse.hs8
-rw-r--r--src/Zettel/Render.hs10
-rw-r--r--src/Zettel/Transclusion.hs8
-rw-r--r--src/Zettel/Types.hs8
10 files changed, 105 insertions, 3 deletions
diff --git a/src/Main.hs b/src/Main.hs
index ae62335..04f6c0a 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -1,5 +1,13 @@
{-# LANGUAGE TemplateHaskell #-}
+-- |
+-- Module : Main
+-- Description : Command-line interface for org-zk
+-- Copyright : (c) 2023, Yann Herklotz
+-- License : GPL-3
+-- Maintainer : git [at] yannherklotz [dot] com
+-- Stability : experimental
+-- Portability : POSIX
module Main where
-- import Data.Char (isAlphaNum, isLetter, isNumber)
diff --git a/src/Zettel.hs b/src/Zettel.hs
index 7c85ae6..535a5b4 100644
--- a/src/Zettel.hs
+++ b/src/Zettel.hs
@@ -1,3 +1,11 @@
+-- |
+-- Module : Zettel
+-- Description : Main Zettel library file
+-- Copyright : (c) 2023, Yann Herklotz
+-- License : GPL-3
+-- Maintainer : git [at] yannherklotz [dot] com
+-- Stability : experimental
+-- Portability : POSIX
module Zettel
( module Zettel.Types,
module Zettel.Render,
diff --git a/src/Zettel/Bibliography.hs b/src/Zettel/Bibliography.hs
index 6186917..42476be 100644
--- a/src/Zettel/Bibliography.hs
+++ b/src/Zettel/Bibliography.hs
@@ -1,25 +1,55 @@
{-# LANGUAGE OverloadedRecordDot #-}
-module Zettel.Bibliography where
+-- |
+-- Module : Zettel.Bibliography
+-- Description : Render bibliography citations to links to org bibliography
+-- Copyright : (c) 2023, Yann Herklotz
+-- License : GPL-3
+-- Maintainer : git [at] yannherklotz [dot] com
+-- Stability : experimental
+-- Portability : POSIX
+--
+-- By default, if no Org bibliography file is provided, the citations are
+-- handled during rendering. However, it is useful to link to any bibliographic
+-- notes that one might already have instead of just citing the works in the
+-- 'Zettel'.
+--
+-- 'handleBibliography' can therefore be used to replace all citations in all
+-- 'Zettel' to links instead. These will then link to the rendered
+-- bibliographic notes about the cited work, which can then include the full
+-- citation as well.
+module Zettel.Bibliography
+ ( handleBibliography,
+ replaceCitation,
+ replaceCite,
+ replaceCites,
+ )
+where
-import Text.Pandoc.Definition (Citation (..), Inline (..), Target (..))
+import Text.Pandoc.Definition (Citation (..), Inline (..), Target)
import Text.Pandoc.Walk (walk)
import Zettel.Types
+-- | Replace the Citation by the link with a description and a target.
replaceCitation :: Citation -> ([Inline], Target)
replaceCitation c =
([Str $ "@" <> zid], ("/bib/" <> zid, ""))
where
zid = citationId c
+-- | Replace a citation by a link to the Org bibliography file.
replaceCite :: Inline -> [Inline]
replaceCite (Cite c _) =
[Str "("] <> map (uncurry (Link mempty) . replaceCitation) c <> [Str ")"]
replaceCite c = [c]
+-- | Replaces all citations by a link to the Org bibliography file.
replaceCites :: [Inline] -> [Inline]
replaceCites = concatMap replaceCite
+-- | If the bibliography is non-empty (i.e. 'zettelGraphBib' is non-empty), then
+-- it replaces all citations in 'Zettel' in 'unZettelGraph' by links to
+-- @\/bib\/citationId@.
handleBibliography :: ZettelGraph -> ZettelGraph
handleBibliography zg =
if null zg.zettelGraphBib then zg else zg {unZettelGraph = walk replaceCites zg.unZettelGraph}
diff --git a/src/Zettel/Common.hs b/src/Zettel/Common.hs
index 515ebd5..5d703e2 100644
--- a/src/Zettel/Common.hs
+++ b/src/Zettel/Common.hs
@@ -1,5 +1,13 @@
{-# LANGUAGE OverloadedRecordDot #-}
+-- |
+-- Module : Zettel.Common
+-- Description : Shared functions used throughout the project
+-- Copyright : (c) 2023, Yann Herklotz
+-- License : GPL-3
+-- Maintainer : git [at] yannherklotz [dot] com
+-- Stability : experimental
+-- Portability : POSIX
module Zettel.Common where
import Data.Char (isAlphaNum, isLetter, isNumber)
diff --git a/src/Zettel/Links.hs b/src/Zettel/Links.hs
index 3ac9a02..dd467de 100644
--- a/src/Zettel/Links.hs
+++ b/src/Zettel/Links.hs
@@ -1,5 +1,13 @@
{-# LANGUAGE OverloadedRecordDot #-}
+-- |
+-- Module : Zettel.Links
+-- Description : Calculate the backlinks and forward links for each Zettel
+-- Copyright : (c) 2023, Yann Herklotz
+-- License : GPL-3
+-- Maintainer : git [at] yannherklotz [dot] com
+-- Stability : experimental
+-- Portability : POSIX
module Zettel.Links where
import Data.List (nub)
diff --git a/src/Zettel/Math.hs b/src/Zettel/Math.hs
index 3e51437..fd335a4 100644
--- a/src/Zettel/Math.hs
+++ b/src/Zettel/Math.hs
@@ -1,3 +1,11 @@
+-- |
+-- Module : Zettel.Math
+-- Description : Wrap math with hugo raw-html markers
+-- Copyright : (c) 2023, Yann Herklotz
+-- License : GPL-3
+-- Maintainer : git [at] yannherklotz [dot] com
+-- Stability : experimental
+-- Portability : POSIX
module Zettel.Math where
import Text.Pandoc.Definition (Inline (..))
diff --git a/src/Zettel/Parse.hs b/src/Zettel/Parse.hs
index 943e343..3f52972 100644
--- a/src/Zettel/Parse.hs
+++ b/src/Zettel/Parse.hs
@@ -1,3 +1,11 @@
+-- |
+-- Module : Zettel.Parse
+-- Description : Parse the org-zettelkasten files and split them into Zettel
+-- Copyright : (c) 2023, Yann Herklotz
+-- License : GPL-3
+-- Maintainer : git [at] yannherklotz [dot] com
+-- Stability : experimental
+-- Portability : POSIX
module Zettel.Parse where
import Data.Default (def)
diff --git a/src/Zettel/Render.hs b/src/Zettel/Render.hs
index 1cdb4bd..c4bb7af 100644
--- a/src/Zettel/Render.hs
+++ b/src/Zettel/Render.hs
@@ -1,5 +1,13 @@
{-# LANGUAGE OverloadedRecordDot #-}
+-- |
+-- Module : Zettel.Render
+-- Description : Render the Zettelgraph to multiple markdown files
+-- Copyright : (c) 2023, Yann Herklotz
+-- License : GPL-3
+-- Maintainer : git [at] yannherklotz [dot] com
+-- Stability : experimental
+-- Portability : POSIX
module Zettel.Render where
import Control.Logging
@@ -11,7 +19,7 @@ import System.FilePath ((<.>), (</>))
import Text.Pandoc.App (applyFilters)
import Text.Pandoc.Builder (HasMeta (..))
import Text.Pandoc.Class (runIOorExplode)
-import Text.Pandoc.Definition (Block (..), Inline (..), Meta (..), MetaValue (..), Pandoc (..))
+import Text.Pandoc.Definition (Block (..), Inline (..))
import Text.Pandoc.Extensions (Extension (..), disableExtension)
import Text.Pandoc.Filter (Environment (..), Filter (..))
import Text.Pandoc.Options (ReaderOptions (..), WriterOptions (..), getDefaultExtensions, multimarkdownExtensions)
diff --git a/src/Zettel/Transclusion.hs b/src/Zettel/Transclusion.hs
index 27d4429..6bc7b2b 100644
--- a/src/Zettel/Transclusion.hs
+++ b/src/Zettel/Transclusion.hs
@@ -1,5 +1,13 @@
{-# LANGUAGE OverloadedRecordDot #-}
+-- |
+-- Module : Zettel.Transclusion
+-- Description : Transclude Zettel recursively
+-- Copyright : (c) 2023, Yann Herklotz
+-- License : GPL-3
+-- Maintainer : git [at] yannherklotz [dot] com
+-- Stability : experimental
+-- Portability : POSIX
module Zettel.Transclusion where
import Data.Map.Strict ((!?))
diff --git a/src/Zettel/Types.hs b/src/Zettel/Types.hs
index 791bc9c..3d3f793 100644
--- a/src/Zettel/Types.hs
+++ b/src/Zettel/Types.hs
@@ -5,6 +5,14 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE StandaloneDeriving #-}
+-- |
+-- Module : Zettel.Types
+-- Description : Type definitions of ZettelGraph
+-- Copyright : (c) 2023, Yann Herklotz
+-- License : GPL-3
+-- Maintainer : git [at] yannherklotz [dot] com
+-- Stability : experimental
+-- Portability : POSIX
module Zettel.Types
( Combine (..),
UseCombine (..),