If you haven't used this for a while or this is your first time, follow these steps.
- Let's make sure that you can edit files!
- I used to use ReText, but it doesn't install anymore.
- Now I might as well create with pyCharm
- Now what? If you are writing a commentary on a sutta, then you probably would like to use palitype.
- After palitype produced the
rst
file, you can see the end resulting html by using `pelican <readme/pelican
Palitype is a preprocessor on markup. It takes text with quotes in different languages. It then:
Reads a strict_yaml file using strictyaml. The yaml file indicates the delimiters that indicate the target text and the mark-up that will envelope the target text.
- Example:
Text is presented that contains English, Pali and Sanskrit.
DELIMITER1 English DELIMITER2 Pali DELIMITER3 Sanskrit DELIMITER4
The first line in the text file refers to the yml file that contains the delimiters .. include:: palitype_instructions.yml
cd palitype
(palitype)% cd content
(palitype)% python ../../palitype/cli.py SN001.txt
The palitype
tests are run:
cd palitype
pipenv run python -m pytest
Some options:
pipenv run python -m pytest -x # stop after first failure
pipenv run python -m pytest --maxfail=2 # stop after two failures
To guage effectiveness of tests, use coverage.py
.
After preprocessing the text file with palitype, run pelican to generate the html files.
cd ~/My\ Buddhism/SN
pelican content
pelican --listen
TO change a theme, see Pelican themes .
but here, the m.css
is used.
The pelicanconf.py
file is
.. literalinclude:: ../../../../../pelicanconf.py :language: python
This is placed in the main directory where pelican
is executed. All the content is in the content
folder beneath it.
The default theme is m-theme-dark.css
but this them will indent all paragraphs by 1.5rem. To avoid this, change this line:
--paragraph-indent:
to:
--paragraph-indent: 0rem;
On web browser, go to http://localhost:8000
Let's use virtualenv as the package manager.
cd py4web/apps/samyutta/palitype/docs
sphinx-quickstart
Added:
sys.path.insert(0, os.path.abspath('..'))
sys.path.append(os.path.abspath('.'))
to the conf.py
. The second line is to read the ipython
directives from
a directory within docs
. iPython directive was placed in there so that the
extensions list in conf.py
looks like:
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.coverage',
'sphinx.ext.napoleon',
'sphinxext.ipython_console_highlighting',
'sphinxext.ipython_directive'
]
The sphinxext
directory was obtained from https://github.com/ipython/ipython/tree/master/IPython
Generate html from this README.rst
file by adding the line:
.. include:: ../README.rst
in the docs/read.rst
.
cd docs
make html
Don't use any spaces in paths. Spaces in pathnames will generate bookmark errors.
conda install -c conda-forge docformatter
docformatter --in-place example.py
docformatter --recursive --in-place dir
yapf
is a python formatter.
conda install -c conda-forge yapf
yapf --recursive --in-place dir
If these settings in setup.cfg
, google styling is used and this has the
least errors after running pylama
.:
[yapf] based_on_style = google spaces_before_comment = 4 split_before_logical_operator = true
https://realpython.com/python-git-github-intro/
(use gitignore.io to generate .gitignore
file using 'Python', 'mac' and 'git' as seeds)
Buddhism % cd SN/py4web/apps/samyutta/palitype
palitype % git config --global user.name "your name goes here"
palitype % git init
Initialized empty Git repository in ...
Add docs/sphinxext/
to .gitignore
To remove staged files use:
palitype % git reset docs/sphinxext/
To commit all
palitype % git commit -am 'Initial commit'
Project uses wily
as mentioned at https://realpython.com/python-refactoring/
wily
analyses the code and calculates a mertic that describes the complexity
of the code.
To guage effectiveness of tests, use coverage.py
.
Database set up uses a postgres docker, so an postgresql image is first downloaded https://hub.docker.com Then:
docker run --name postgres -p 5433:5432 -v /Users/ben/Databases/sn:/var/lib/postgresql/data -e POSTGRES_PASSWORD=time67docker
Note that:
The port has changed for the host. The host port is 5433
The location of the database is in a host directory. So in
settings.py
:# DB_FOLDER: Sets the place where migration files will be created # and is the store location for SQLite databases DB_FOLDER = "/Users/ben/Databases/sn/py4web" DB_URI = "postgres://postgres:time67docker@localhost:5433/postgres"
Now in common.py
, db
is declared with the check_reserved = ["postgres"]
:
db = DAL(
settings.DB_URI,
folder=settings.DB_FOLDER,
pool_size=settings.DB_POOL_SIZE,
migrate=settings.DB_MIGRATE,
fake_migrate=settings.DB_FAKE_MIGRATE,
check_reserved=['postgres'],
)