[][src]Function libzettels::examples::generate_bare_examples

pub fn generate_bare_examples<P: AsRef<Path>>(dir: P) -> Result<()>

Takes the path to a directory and creates a directory structure with set of example files inside it.

The result can be represented as follows:

examples
└── Zettelkasten
    └── file1.md
    └── file2.md
    └── file3.md
    └── subdir
        └── file4.md
        └── file5.md
    └── onlies
        └── markdown-only.md
        └── pure-yaml.yaml
    └── .hiddendir
        └── .hiddenfile2.txt
        └── a-file.txt
    └── .gitignore
    └── .zettelsignore
└── config

A few notes:

  • The zettel files in examples/Zettelkasten contain nonsense text and are (probably just as nonsensically) interlinked with each other in various ways.
  • .gitignore's contents are simply /.*, which means all hidden files and directories are ignored.
  • The subdirectory onlies contains files that are not proper zettel files. One is a markdown file without a YAML-header, the other a YAML-file (might be a pandoc metadata file). They are still added to the index, with making the best of the present data and sensible defaults:
    1. The entry for markdown-only.md looks like this:
      onlies/markdown-only.md:
         title: untitled
         links:
             - file2.md
         followups: []
         keywords: []
      
      Everything was filled with empty or default values, but the one link in the markdown was parsed and correctly added to the zettels links.
    2. The entry for pure-yaml.yaml looks like this:
      onlies/pure-yaml.yaml:
         title: Pure Yaml
         links: []
         followups: []
         keywords:
             - example
             - pureyaml
      
      All YAML-fields that make sense for a Zettel, were used, the rest was filled with empty values.

Errors

  • std::io::Error of the InvalidInput kind if the provided path is not a directory or cannot be accessed.
  • A variety of other std::io::Errors for problems with creating and writing to the files in the directory.