Python Org-Mode Template Builder.
Project description
Org-template-builder
pip install org-template-builder
python -m orgtemp myprojectname --author myname
The orgtemp
process will raise an exception if the directory is not empty. It won’t exit if it contains dotfiles, like .git
or .projectile
. This means that the best way to use it is the following.
mkdir myprojectname && cd myprojectname && python -m orgtemp myprojectname
This behaviour is to protect (in case of user mistake) overwriting existing configurations from other org-template-builder projects, individual checking/versioning/uninstalling has not been implemented.
The template will attempt to initialize a git repo with the subprocess
module and add submodules to it but it won’t make any commits. It will attempt to create and checkout a branch named main
, to avoid using the default master
name.
Template Builder Arguments
Project Name
Whenever org-template-builder
installs all the parts, it will use whatever =--project=
name was given to it to modify the default of a few files:
- The first
.org
file’s name. - The title and first header of the same file.
- The
PROJECT_NAME
variable in theMakefile
. - All references to
PROJECT_NAME
files in theMakefile
.
However, when copying the “project named” .md
file to the root directory, Makefile
will rename it to README.md
.
If no project name is given, it will be set to readme.
Author Name
The author name argument is optional, defaults to ""
and it is only added to the header of the .org
file with the name of the project.
Introduction
This is an org-mode template for literate programming. The HTML theme is a fork of https://github.com/fniessen/org-html-themes.
The Makefile options are:
make update
will go over all submodules and pull any changes.make
should calltangle.el
andpublish.el
withoutforce
, which renders all the HTML and Markdown and copies all the static files topublic
.make clean
should remove all directories inpublic
before running aforce
version ofpublish
.make commit
should runpublish
(non-forced) and then add and commit with automated timestamp.
make update
make
make clean
..
├── config
├── docs
├── public
│ ├── build
│ └── resources
│ ├── images
│ ├── installer
│ │ └── config
│ └── theme
│ ├── css
│ ├── js
│ └── lib
│ └── js
├── resources
│ ├── data
│ ├── images
│ └── theme
│ ├── css
│ ├── js
│ └── lib
│ └── js
├── src
└── tests
23 directories
- Public: HTML directory for web.
- Resources: Copies of all files from root/resources specified on publish.el.
- Build: This is the equivalent of the
src
directory but for the HTML renders.
- Resources: All static files, plus the
theme
submodule fromorg-theme
repository. - Docs: The equivalent of
src
but for Markdown renders. - Src: Where all org and tangled code files live.
- Tests: Reserved for writing tests with our without org files.
All files in resources
that match the types specified in publish.el
will be copied to /public/resources
.
Having the src
and build
folders at the same tree level helps when accessing the equivalent resources
folder from either directory.
Code Examples
Shell Example
Shell source blocks don’t tangle as they are normally one liners. This particular line just sets the local Python environment via pyenv
, I don’t need a venv
for this demo.
We must make sure that :dir
is set to the parent directory ..
.
pyenv local 3.7.13 && cat .python-version
3.7.13
Now let’s install a Python library with pip
. Once ran, we are setting this block to :eval no
.
This is where we would use poetry
or activate or venv
.
pip install tabulate && pip list | grep tabulate
SQL Example
This is an SQL query for the database specified in the org-header.config
file, which is the pagila sample database. For changing the sql info it’s always better to override the header-args
in the current document while using the original configuration as reference.
SELECT
CONCAT(customer.last_name, ', ', customer.first_name) AS customer,
address.phone,
film.title
FROM
rental
INNER JOIN customer ON rental.customer_id = customer.customer_id
INNER JOIN address ON customer.address_id = address.address_id
INNER JOIN inventory ON rental.inventory_id = inventory.inventory_id
INNER JOIN film ON inventory.film_id = film.film_id
WHERE
rental.return_date IS NULL
AND rental_date < CURRENT_DATE
ORDER BY
title
LIMIT 5;
customer phone title
OLVERA, DWAYNE 62127829280 ACADEMY DINOSAUR
HUEY, BRANDON 99883471275 ACE GOLDFINGER
OWENS, CARMEN 272234298332 AFFAIR PREJUDICE
HANNON, SETH 864392582257 AFRICAN EGG
COLE, TRACY 371490777743 ALI FOREVER
Elisp Example
Elisp blocks do not tangle by default either as they are mostly functions to evaluate on-the-go while using emacs.
(run-python)
(emacs-version)
GNU Emacs 28.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95))
of 2022-05-11
Python Example
Python uses a session, as specified in the ../config/org-header.config
, so there must be a (run-python)
session running.
print("TODO: finish this part.")
TODO: finish this part.
Admonitions
Support for HTML export admonitions. Four colors for a few options.
This is a note.
This is a hint.
This is a caution.
This is a warning.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for org-template-builder-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1560aa1f27df4d0bf3cb1f41f1ec96ca4e3fee8a00bf2b4173b31a2e15f6c476 |
|
MD5 | 71783d9be86fd96a7b0fb391fae62727 |
|
BLAKE2b-256 | f1991d63dda16e3a15848363a65588f26109c5a3a1ab2b149c52035d5df96028 |
Hashes for org_template_builder-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52cf17bfdd66ceb4e171e09627e7ce7da289e8474a4067516aa1e44ed1f674fd |
|
MD5 | b05793e9e9f29a18b14507406a19da3e |
|
BLAKE2b-256 | 7a9847944ac5ad08b9e1ef52900646ab02fbcf6985313f14f3634b73874bc51e |