Commit d365c079 authored by ak's avatar ak
Browse files

include jrnl

parent c4889d92
Pipeline #2583 failed with stage
in 11 seconds
......@@ -13,15 +13,15 @@ This software is highly adapted to a particular workflow and not for everyone, t
<figcaption><a href="https://git.c3pb.de/ak/pykyll/-/tree/master/docs">pykyll self doc demo site</a></figcaption>
</figure>
[unziped](https://pykyll.harmlos.info/html_out.zip) into your projects `docs/html_out` subfolder. This document is getting ahead of itself. Read the friendly
You can download and unzip a archive of [this page]() to get you going into your `docs/html_out`.
## Documentation
- [Web Site](https://pykyll.harmlos.info/pykyll) generated from `"""docstrings"""` by pdoc3
- [Markdown](https://git.c3pb.de/ak/pykyll) docs.
- This web site generated from the repository [`README.md`](https://git.c3pb.de/ak/pykyll/-/blob/master/README.md)
- This page generated from the repository [`README.md`](https://git.c3pb.de/ak/pykyll/-/blob/master/README.md)
`pykyll`s aim is to ease maintaining documentation of software projects.
`pykyll`s aim is to ease maintenance cost in documentation of software projects and works for me.
### Install
......@@ -52,6 +52,8 @@ and put the mini web site into `docs/html_out`.
Will turn your projects README.md into a mini site in `docs/html_out` and generate a description from your code comments using `pdoc`. Check out pykylls own web site at is has *Gone and documented itself!*
If you are running a [jrnl](https://jrnl.sh/en/stable/), use the value for `name` from the configuration file as a `@tag`. Pykyll will stick the whole jrnl on to your README.md, thus making for an [micro blogging solution]().
### Lokal development web server
Using Pythons `http.server`
......@@ -89,8 +91,6 @@ Please consider the importance of line 1.
> This is a quote
### Pygments
As the name of the code style sheet is simply hard coded, you may change the source code or you may generate a style sheet as recommended in the official pygments docs like so:
......@@ -119,11 +119,8 @@ Which naturally goes into your html_out as this is just a mini site to get somet
---
<figure>
<a href="https://ak.harmlos.info/#software">
<img class="icon" src="https://harmlos.info/ak.png">
</a>
<figcaption>2021</figcaption>
</figure>
[TOC]
Pykyll is a command line tool written in Python that mimiks Jekyll in its result and in the way information is stored. The result being a static web site that is build from essentially markdown text files. The name is obviously a pun of some sort.
## [Repository view](https://git.c3pb.de/ak/pykyll) 👉 [Web view](https://pykyll.harmlos.info) 👀
![[Featured Views](images/Screenshot_2.png)](images/Screenshot_2.png)
> The best software is the one in which you see everything on first glance
>
> ––– A certain freaky spider
# Command Line View & More
![[Peek](images/peek.gif)](images/peek.gif)
![[CLI Features](images/zsh_001.png)](images/zsh_001.png)
## Get Started
Clone git reopository using the main branch
```bash
❯ git clone https://git.c3pb.de/ak/pykyll.git
❯ cd pykyll
❯ git submodule update --init --recursive
```
#### Run program
```bash
❯ chmod +x main.py
❯ ./main.py
```
**Beginner Tip** To adjust CHECK readability search for `glancetime` in `main.py`. The value represents seconds. Welcome to Python Programming.
## Manage a git repository with Pykyll
Pykyll is being developed to serve as a git sub-module within a git repository of makdown notes. What does that even mean?
## Examples
### Basic
Basic examples are best browsed in the [web view](https://ak.pages.c3pb.de/pykyll)
### Production
#### [Talks](https://talks.harmlos.info/)
Subraum Talks held or hosted by ak during wednesdays open chaos event between 2019 and now
#### [mOpsMan](https://mopsman.harmlos.info)
Projects Management for TaskWarrior
### How to
Set up a fresh git repository $repo for documentation with Pykyll:
```bash
❯ mkdir $repo
❯ cd $repo
❯ git init
❯ git submodule add https://git.c3pb.de/ak/pykyll.git
❯ ln -s pykyll/main.py main.py
❯ ./main.py
```
Missing python modules will be installed using pip during first run. You may have to satisfy the dependencies by installing the required modules from pip yourself if it does fail. This mainly concernes pandoc which should live on your system anyway because its cool.
To enable [taskwarrior integration into Pykylls user interface](examples/taskwarrior), set `taskwarrior` in `./config.yml` to `true`.
## Documentation
![y is missing](images/pykyll_logo.png)
The software is the documentation, i.e. help is provided within the software. This is just a friendly tool that aims to be useful.
Docs Extended can be read on the command line [r][p] Docs Extended. In repository or web view they are [here](/examples)
README.md
<a href="https://ak.harmlos.info"><img src="images/ak.png" class="icon"></a>
---
No preview for this file type
......@@ -20,15 +20,15 @@ This software is highly adapted to a particular workflow and not for everyone, t
<figcaption><a href="https://git.c3pb.de/ak/pykyll/-/tree/master/docs">pykyll self doc demo site</a></figcaption>
</figure>
[unziped](https://pykyll.harmlos.info/html_out.zip) into your projects `docs/html_out` subfolder. This document is getting ahead of itself. Read the friendly
You can download and unzip a archive of [this page]() to get you going into your `docs/html_out`.
## Documentation
- [Web Site](https://pykyll.harmlos.info/pykyll) generated from `"""docstrings"""` by pdoc3
- [Markdown](https://git.c3pb.de/ak/pykyll) docs.
- This web site generated from the repository [`README.md`](https://git.c3pb.de/ak/pykyll/-/blob/master/README.md)
- This page generated from the repository [`README.md`](https://git.c3pb.de/ak/pykyll/-/blob/master/README.md)
`pykyll`s aim is to ease maintaining documentation of software projects.
`pykyll`s aim is to ease maintenance cost in documentation of software projects and works for me.
### Install
......@@ -59,6 +59,8 @@ and put the mini web site into `docs/html_out`.
Will turn your projects README.md into a mini site in `docs/html_out` and generate a description from your code comments using `pdoc`. Check out pykylls own web site at is has *Gone and documented itself!*
If you are running a [jrnl](https://jrnl.sh/en/stable/), use the value for `name` from the configuration file as a `@tag`. Pykyll will stick the whole jrnl on to your README.md, thus making for an [micro blogging solution]().
### Lokal development web server
Using Pythons `http.server`
......@@ -96,8 +98,6 @@ Please consider the importance of line 1.
> This is a quote
### Pygments
As the name of the code style sheet is simply hard coded, you may change the source code or you may generate a style sheet as recommended in the official pygments docs like so:
......@@ -126,11 +126,22 @@ Which naturally goes into your html_out as this is just a mini site to get somet
---
<figure>
<a href="https://ak.harmlos.info/#software">
<img class="icon" src="https://harmlos.info/ak.png">
</a>
<figcaption>2021</figcaption>
</figure>
[TOC]
project:pykyll blog
# 2021
## December
### 2021-12-05 16:45 First Post.
This is the first post to pykylls blog as this feature just got enabled.  In conjunction with mopsman jrnl has become a welcome addition to the stack. Now its possible to generate a simple blog if you keep the README short.
---
......@@ -18,6 +18,10 @@ Functions
: Pykyll Documentation Fun.
`check()`
: Checks by looping pre-commit-hooks.
`edit(new: bool = <typer.models.OptionInfo object>)`
: Edit one one of the projects files.
......@@ -41,6 +45,10 @@ Defaults to sftp.
Runs various checks and makes sure everything is in place and checks out correctly.
`jrnl()`
: Inject jrnl into html output
`read()`
: Read your docs in the terinal.
......
......@@ -6,10 +6,6 @@ Functions
---------
`get_char(prompt='Press Any Key')`
: Pause, return key presssed Screen
`menu(choices, prompt='')`
: Ask for user interaction
......
......@@ -66,9 +66,15 @@ output_dir (str, optional): [description]. Defaults to "".
Returns:
[type]: [description]
`inject_jrnl(self)`
: Inject jrnl into html output
`make_docs(self)`
: check content_directories recursively
`pause(self, prompt='Press Any Key')`
: Pause, return key presssed Screen.
`print(self, stringy)`
:
......
......@@ -46,6 +46,14 @@ def callback(ctx: typer.Context):
if ctx.invoked_subcommand == None:
pkll.cons.clear()
pkll.display_header("Pykyll Help")
pkll.cons.print(
"pykyll must be run from within your projects virtual environment: ", end=""
)
try:
pkll.cons.print(os.environ["VIRTUAL_ENV"])
except KeyError:
pkll.cons.print("\nActivate: poetry shell or manage it yourself.")
pkll.cons.print("")
pkll.print(ctx.get_help())
......@@ -219,6 +227,27 @@ def browse(publish: bool = typer.Option(default=False, help="Publish")):
pkll.print("Browse Command: Not yet implemented.")
@app.command()
def jrnl():
"""Inject jrnl into html output"""
# init()
pkll.display_header("Pykyll injecting jrnl into docs/html")
pkll.base_check()
project_name = pkll.conf["name"]
output = os.popen("jrnl @" + project_name + " --format=md").readlines()
stringy = ""
for line in output:
line = line.replace("@" + project_name, "")
if not line == "":
stringy = stringy + line
if os.path.isfile("index.md"): # assuming we are in docs
post = frontmatter.load("index.md")
post.content = post.content + " \n\n" + stringy
pkll.cons.print(Markdown(post.content))
with open("docs/index.md", "w") as f:
f.writelines(frontmatter.dumps(post))
@app.command()
def build():
"""Build static web site in docs/html_out"""
......@@ -226,6 +255,9 @@ def build():
pkll.display_header("Pykyll building docs and docs/html")
pkll.base_check()
pkll.make_docs()
# jrnl()
pkll.display_header("Pykyll pre-commit hooks")
check()
# pkll.print("Build Command: Not yet implemented.")
......@@ -282,6 +314,22 @@ def status():
pkll.print(pkll.show(verbose=False))
@app.command()
def check():
"""Checks by looping pre-commit-hooks."""
loop_end = False
while not loop_end:
pkll.display_header("git status")
os.system("git status -s")
pkll.display_header("git add . and pre-commit hooks")
os.system("git add .")
os.system(".git/hooks/pre-commit")
print("")
char = pkll.pause("<a> to loop again.")
if not char == "a":
loop_end = True
@app.command()
def read():
"""Read your docs in the terinal."""
......
"""menutools"""
import getch
import os
import re
import textwrap
......@@ -72,21 +71,6 @@ def menu_preview(choices, prompt="", preview_command=""):
return main_menu.show()
# Pause Function
def get_char(prompt="Press Any Key"):
"""
Pause, return key presssed Screen
"""
print(prompt)
try:
char = getch.getch()
except OverflowError:
char = "Bad Character"
return char
def shorten(text="", short=False):
# wrapper = TextWrapper()
if not short:
......
......@@ -12,7 +12,9 @@ import subprocess
import sys
import threading
import time
import webbrowser
# import webbrowser
import getch
from getpass import getuser
from time import sleep
......@@ -34,7 +36,6 @@ from rich.table import Table
from rich.traceback import install
from pykyll.menutools import (
get_char,
menu,
menu_preview,
menu_preview_show_item,
......@@ -605,6 +606,30 @@ class Pykyll:
self.print("Please run `[magenta]pykyll init[/magenta]` first.")
sys.exit(1)
def inject_jrnl(self):
"""Inject jrnl into html output"""
# init()
self.display_header("Pykyll injecting jrnl into docs/html")
project_name = self.conf["name"]
output = os.popen("jrnl @" + project_name + " --format=md").readlines()
stringy = ""
for line in output:
line = line.replace("@" + project_name, "")
if not line == "":
stringy = stringy + line
if os.path.isfile("index.md"): # assuming we are in docs
post = frontmatter.load("index.md")
post.content = (
post.content
+ f"\n\nproject:{project_name} blog\n\n"
+ stringy
+ "\n\n---"
)
self.cons.print(Markdown(post.content))
if post:
with open("index.md", "w") as f:
f.writelines(frontmatter.dumps(post))
def make_docs(self):
"""
check content_directories recursively
......@@ -639,6 +664,7 @@ class Pykyll:
os.path.join(self.conf["name"], file),
os.path.join("html_out", self.conf["name"], file),
)
self.inject_jrnl()
with open(os.path.join("index.md")) as f:
index_frontmatter = frontmatter.load(f)
html_body = markdown.markdown(
......@@ -689,6 +715,15 @@ class Pykyll:
self.cons.print(markeddown)
self.cons.print(markeddown)
def pause(self, prompt="Press Any Key"):
"""Pause, return key presssed Screen."""
print(prompt)
try:
char = getch.getch()
except OverflowError:
char = "Bad Character"
return char
def serve(self):
"""Serve current docs version on localhost."""
self.base_check() # make sure we are in the right directory
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment