Add warning and tip macros to TiddlyWiki

I am a *very* big fan of TiddlyWiki. I use it to document just about anything I figure out while working on projects, setting up systems, … Anything I would otherwise quickly forget. It makes it easier to add structure to random tidbits of information, and forcing myself to document while I work on something helps to stay focused on a certain goal.

I noticed some of the “official documentation” Tiddlers had options to emphasize tips and (more importantly) warnings, such as these:

While there seems to be an endless list of special tricks one can do with a TiddlyWiki, this was something that seemed really useful so I decided I needed to find out how to recreate them…

Add the macros and stylesheets

In the examples below, replace “Deevee” with any other folder name where you want to gather your own custom macros and stylesheets…

  • Create a new tiddler, name it $:/Deevee/macros
  • Add the tag $:/tags/Macro
  • Past in the following contents:
\define .tip(_) <div class="doc-icon-block"><div class="doc-block-icon">{{$:/core/images/tip}}</div>$_$</div> 
\define .warning(_) <div class="doc-icon-block"><div class="doc-block-icon">{{$:/core/images/warning}}</div>$_$</div>
  • Create another tiddler, name it $:/Deevee/styles
  • add the tag $:/tags/Stylesheet
  • paste in the following contents:
.doc-icon-block {
	border-left: 2px solid <<colour code-border>>;
	margin-left: 3em;
	padding-left: 0.6em;
	position: relative;
}

.doc-block-icon {
	position: absolute;
	left: -3em;
	top: 0.2em;
}

Using the macros

Simply use:

<<.tip “your text”>>

<<.warning “your text”>>

Setting up Visual Studio Code for Python development (on Linux)

The following is a brief guide to reinstalling/setting up Visual Studio Code (VSC) on a new Linux system. The main use is Python development. As such, it is very brief and mostly for my own documentation.

Install VSC

sudo snap install --classic code

Install Python packages

! DO THIS OUTSIDE OF AN ACTIVE VIRTUAL ENVIRONMENT !

  • linting (flake8): python -m pip install pyflakes pycodestyle mccabe flake8
  • Refactoring (rope): python -m pip install rope
  • Formatting (Yapf): python -m pip install yapf
  • Type checking (mypy): python -m pip install -U mypy --user
  • Flake8 Bugbear: python -m pip install flake8-bugbear, then check if installed with flake8 --version (should include flake8-bugbear)
  • Sphinx/RST support: python -m pip install doc8 rstcheck sphinx-autobuild
  • Snooty languageserver: python -m pip install snooty-lextudio

Install and configure plugins

Select interpreter

Add

"python.pythonPath": "/usr/bin/python3",

to $HOME/.config/Code/User/settings.json

Set up linting

List of possible linters and how to configure them

Open user settings and

  • set Python > linting: flake8 path, to C:\Python39\Scripts\flake8.exe
  • Add max-line-length=99 to Python > Linting: Flake8 Args
  • Enable flake8

or add

    "python.linting.flake8Path": "C:\\Python39\\Scripts\\flake8.exe",
    "python.linting.flake8Args": [
        "max-line-length=99"
    ],
    "python.linting.flake8Enabled": true,

to %APPDATA%\Code\User\settings.json (Windows) or $HOME/.config/Code/User/settings.json (Linux)

MyPy:

  • Install package

python -m pip install -U mypy --user

  • Enable
    "python.linting.mypyEnabled": true,
    "python.linting.mypyArgs": [],
    "python.analysis.typeCheckingMode" :"basic",
    "python.linting.mypyPath": "C:\\Users\\dieterv\\AppData\\Roaming\\Python\\Python39\\Scripts\\mypy.exe",

to ~/.config/Code/User/settings.json

more mypy info

Autodocstring

Add the following to your settings.json

"autoDocstring.docstringFormat": "google",
"autoDocstring.guessTypes": true,
"autoDocstring.generateDocstringOnEnter": true,
"autoDocstring.includeExtendedSummary": true,
"autoDocstring.quoteStyle": "\"\"\"",