Skip to main content

Project patterns like I like them

Project description

Motllo

Repository templates just like I like them

Motivation

It can be due to a bit of OCD and a bit of Knuth.

  • Most "project template" systems (that let you create a repository with everything set up to use a library) need a specific repository for it (cookiecutter, giter8, GitHub's own template repositories). This feels weird to me, like needing a house to build a new house.
  • I prefer more compact stuff I can read. Even better if I can document

So, here's motllo

[1284; del ll. mŏdŭlus 'mesura; mòdul', dimin. de modus 'mesura']
 	
m 1 1 TECNOL METAL·L ART Peça amb una cavitat en la qual hom introdueix 
una substància en forma de pols, de pasta o líquida per tal que, en 
passar a l'estat sòlid, agafi la forma de la cavitat. 

Description

Motllo can convert a folder structure/repository (it more or less handles .gitignore rules) into a Markdown document with:

  • A "Tree structure" section
  • Optionally, replacements to apply to the structure via the command line tool
  • A tree representation of the folder structure you want (similar to the one generated by the tree UNIX utility, but in Python, thanks to a Stackoverflow answer by Aaron Hall) inside of a code block
  • Optionally, section links
  • Sections, titled with the filepath described in the tree
  • Optionally, replacement blocks for this filepath
  • Code blocks (with possibly text describing what they are there for). All code blocks within a section are merged into that file

Example

You can see an example of a basic Python CLI tool (like this one) as a template, with replacements and comments here.

I plan on adding more examples at some point. New examples welcome!

Usage

The most easy uses are

motllo markdown . -o some_markdown.md

to generate the Markdown template from a repository, which will respect nested and global .gitignore and then

motllo build markdown_template.md -o /wherever/ -r "project:cool-new-project" -r "version:0.0.1"

Here are the commands as shown in the CLI

Usage: motllo [OPTIONS] COMMAND [ARGS]...

Options:
  --debug  Set log level to debug
  --help   Show this message and exit.

Commands:
  build     Build a file/folder structure based on a Markdown document at...
  markdown  Generate a Markdown template from a folder or repository at PATH
  tree      Generate only the visual folder tree (like the UNIX tree...

Usage: motllo markdown [OPTIONS] PATH

  Generate a Markdown template from a folder or repository at PATH

Options:
  -x, --max-length INTEGER      Maximum amount of lines to write in the
                                markdown, for each file. Use -1 for `all of
                                them`

  -o, --output TEXT             Destination markdown file  [required]
  --ignore TEXT                 Glob patterns to ignore, comma separated
                                between quotes like "*.py,*.c,*.scala"

  --gitignore / --no-gitignore  Use local and global gitignores, yes by
                                default

  --help                        Show this message and exit.

Usage: motllo build [OPTIONS] PATH

  Build a file/folder structure based on a Markdown document at PATH

Options:
  -o, --output TEXT     Destination path to create everything  [required]
  -r, --replace TEXT    Multiple replacement rules separated by colons, like
                        -r "$PROJ:world_domination", -r"$TOOLS:python"

  --dry-run / --commit  Dry run by default so you can see what it does
  --help                Show this message and exit.

Usage: motllo tree [OPTIONS] PATH

  Generate only the visual folder tree (like the UNIX tree command)

Options:
  --gitignore / --no-gitignore  Use local and global gitignores, yes by
                                default

  --help                        Show this message and exit.

Is it safe to use?

Well, in dry run mode it will tell you what it will write, so pretty much yes. Don't blame me if it fails. Of course, I'd be happy to see it fail in the wild and improve it.

Next steps

I want to refactor big chunks of the internals (I don't like parts of the API), and add some more testing. I was a bit liberal with the final stages: I tested the tree-to-folder pretty extensively, but I didn't really test tree-to-markdown or markdown-to-tree as thoroughly as I would like. The latter should be pretty easy.

I will probably spin out the markdown parser (which was stolen from the one I wrote for bear-note-graph) into its own library

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

motllo-0.1.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

motllo-0.1.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file motllo-0.1.0.tar.gz.

File metadata

  • Download URL: motllo-0.1.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.4 Darwin/18.7.0

File hashes

Hashes for motllo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0ece83496ad479d8d020e2f28ecf6966d1633d26ce15d7adae4b7034bef9fa41
MD5 f7d35cc0524d3f594ae0bc3ed5c0b97e
BLAKE2b-256 9eb4f718560a72eaec0c3a97739db9c5c029b109de43be5dd94981f53394956b

See more details on using hashes here.

Provenance

File details

Details for the file motllo-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: motllo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.7.4 Darwin/18.7.0

File hashes

Hashes for motllo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7953712c8a210f81243e65986aaf8443c6f28d7bde14293301ce323728364463
MD5 067f0ce8eb500a7c8f68ce9b52817c14
BLAKE2b-256 ec3f4b0c8db40605d6312726cfbf44156ef966b60d3cec45cc44733001a28025

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page