Documenation for hyperdiary¶
hyperdiary¶
A command line tool for writing diaries with hyperlinks. Free software, licensed under MIT license.
Installation¶
hyperdiary requires Python version 3.5 or later. Once you have Python and pip installed on your machine (and available in your path) you can install hyperdiary by executing
pip install hyperdiary
Setup¶
A project file hyperdiary.json is required to setup your diary. It should be of this form:
{
"sources": [
"2019/05.yaml",
"2019/06.yaml"
],
"expected": [
{"start": "2019-05-01", "end": "2019-05-01"},
{"start": "2019-06-09", "end": "2019-06-10"}
],
"localization": {
"months": ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
"date_fmt": "%-d.%-m.%Y"
}
}
You diary content itself is entered in yaml files like this (2019/06.yaml):
2019-06-09:
- Some entry goes here with a $special_identity|link
- This entry is +surprise tagged +mytag +nexttag
- This entry contains nothing new
2019-06-10:
- Same $special_identity|link again and $New_Identity|NewIdentity
- $test +mytag
Use $target|linktext to create a hyperlink to target showing text linktext. Use +mytag to add tag mytag.
Usage¶
usage: hyperdiary [-h]
{check,stats,html,htmlfolder,hugo,tiddlers,tiddlywiki,view}
...
The hyperdiary main command line interface.
optional arguments:
-h, --help show this help message and exit
subcommands:
{check,stats,html,htmlfolder,hugo,tiddlers,tiddlywiki,view}
Available subcommands
check Check entire diary for integrity up-to-dateness
stats Calculate impressive diary statistics
html Export diary to html
htmlfolder Export diary to html in folders
hugo Export diary to hugo static site format
tiddlers Export diary to tiddlywiki tiddlers format
tiddlywiki Export diary to tiddlywiki
view View entries on command line
Installation¶
Stable release¶
To install hyperdiary, run this command in your terminal:
$ pip install hyperdiary
This is the preferred method to install hyperdiary, as it will always install the most recent stable release.
If you don’t have pip installed, this Python installation guide can guide you through the process.
From sources¶
The sources for hyperdiary can be downloaded from the Github repo.
You can either clone the public repository:
$ git clone git://github.com/luphord/hyperdiary
Or download the tarball:
$ curl -OL https://github.com/luphord/hyperdiary/tarball/master
Once you have a copy of the source, you can install it with:
$ python setup.py install
hyperdiary¶
hyperdiary package¶
Submodules¶
hyperdiary.diary module¶
-
class
hyperdiary.diary.
DayEntry
(dt: datetime.date, lines: List[str])[source]¶ Bases:
object
Diary entry for a specific date, contains multiple lines of text.
-
class
hyperdiary.diary.
Diary
(hyperdiary_json: Mapping[KT, VT_co])[source]¶ Bases:
object
-
class
hyperdiary.diary.
Token
(type: hyperdiary.diary.TokenType, text: str, ref: str = None)[source]¶ Bases:
object
-
class
hyperdiary.diary.
TokenType
[source]¶ Bases:
enum.Enum
An enumeration.
-
Id
= 3¶
-
Tag
= 2¶
-
Text
= 1¶
-
>>> line = "+tag1 +tag2 some content goes here +tag3" >>> res = [t.text for t in find_tags(line)] >>> res == ["tag1", "tag2", "tag3"] True
hyperdiary.html module¶
-
hyperdiary.html.
append_li_a
(ul: hyperdiary.htmltags.HTMLElement, text: str, href: str) → None[source]¶
-
hyperdiary.html.
day_to_html
(current: datetime.date, entry: Iterable[str], localization: hyperdiary.localization.Localization, link_to_id_fn: Callable[[Optional[str]], str] = None) → hyperdiary.htmltags.HTMLElement[source]¶
-
hyperdiary.html.
diary_to_html_folder
(diary_instance: hyperdiary.diary.Diary, folder: str) → None[source]¶
-
hyperdiary.html.
rel_path
(spath: Union[datetime.date, str, int]) → hyperdiary.simplepath.RelativePath[source]¶
hyperdiary.htmltags module¶
Bases:
object
hyperdiary.hugo module¶
hyperdiary.localization module¶
-
class
hyperdiary.localization.
Localization
(months: List[str] = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], days_short: List[str] = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], date_fmt: str = '%Y-%m-%d')[source]¶ Bases:
object
-
format_date
(dt: datetime.date) → str[source]¶ Format to localized string. >>> l = Localization() >>> l.format_date(date(2019, 11, 3)) ‘2019-11-03’ >>> l = Localization(date_fmt=’%d.%m.%Y’) >>> l.format_date(date(2019, 11, 3)) ‘03.11.2019’
-
get_day_short
(i: int) → str[source]¶ Get the localized name of day i (zero-based index starting Monday). >>> l = Localization() >>> l.get_day_short(0) ‘Mon’ >>> l.get_day_short(6) ‘Sun’ >>> l.get_day_short(7) Traceback (most recent call last): … AssertionError >>> Localization(days_short=[‘Just Mon’]) Traceback (most recent call last): … AssertionError >>> l2 = Localization(days_short=list(‘1234567’)) >>> l2.get_day_short(3) ‘4’ >>> l2.get_day_short(6) ‘7’
-
get_month
(i: int) → str[source]¶ Get the localized name of month i (zero-based index). >>> l = Localization() >>> l.get_month(0) ‘January’ >>> l.get_month(11) ‘December’ >>> l.get_month(12) Traceback (most recent call last): … AssertionError >>> Localization(months=[‘Just January’]) Traceback (most recent call last): … AssertionError >>> l2 = Localization(months=list(‘123456789ond’)) >>> l2.get_month(3) ‘4’ >>> l2.get_month(10) ‘n’
-
hyperdiary.simplepath module¶
hyperdiary.stats module¶
hyperdiary.tiddlywiki module¶
-
class
hyperdiary.tiddlywiki.
Tiddler
(fname: Union[pathlib.Path, str], **fields)[source]¶ Bases:
object
-
static
from_entry
(dt: datetime.date, entry: Iterable[str], localization: hyperdiary.localization.Localization) → hyperdiary.tiddlywiki.Tiddler[source]¶
-
text
¶
-
title
¶
-
static
-
hyperdiary.tiddlywiki.
diary_to_tiddlers
(diary_instance: hyperdiary.diary.Diary) → Iterator[hyperdiary.tiddlywiki.Tiddler][source]¶
-
hyperdiary.tiddlywiki.
diary_to_tiddlers_export
(diary_instance: hyperdiary.diary.Diary, tiddler_dir: Union[pathlib.Path, str]) → None[source]¶
-
hyperdiary.tiddlywiki.
diary_to_tiddlywiki_export
(diary_instance: hyperdiary.diary.Diary, file: Union[pathlib.Path, str], tiddlywiki_base_file: Union[pathlib.Path, str]) → None[source]¶
-
hyperdiary.tiddlywiki.
make_tiddler_filename
(o: Union[str, datetime.date]) → str[source]¶ >>> make_tiddler_filename(" Frühstück Ähre Grüße Föhn") 'fruehstueck-aehre-gruesse-foehn.tid' >>> make_tiddler_filename("a.v-_'üöß' tiddler") 'av-_ueoess-tiddler.tid' >>> make_tiddler_filename(date(2019, 2, 3)) '2019-02-03.tid'
hyperdiary.view module¶
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/luphord/hyperdiary/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.
Write Documentation¶
hyperdiary could always use more documentation, whether as part of the official hyperdiary docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/luphord/hyperdiary/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up hyperdiary for local development.
Fork the hyperdiary repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/hyperdiary.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv hyperdiary $ cd hyperdiary/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 hyperdiary tests $ python setup.py test or py.test $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 3.5, 3.6 and 3.7. Check https://travis-ci.com/github/luphord/hyperdiary/pull_requests and make sure that the tests pass for all supported Python versions.
Deploying¶
A reminder for the maintainers on how to deploy. Make sure all your changes are committed (including an entry in HISTORY.rst). Then run:
$ bumpversion patch # possible: major / minor / patch
$ git push
$ git push --tags
Travis will then deploy to PyPI if tests pass.
Credits¶
Development Lead¶
- luphord <luphord@protonmail.com>
Contributors¶
None yet. Why not be the first?
History¶
0.6.1 (2020-10-21)¶
- add support for Python 3.8
- upgrade to flake8 3.8.4 and fix linter issues
- replace deprecated test command
- move to travis-ci.com
0.6.0 (2019-11-29)¶
- promote status to alpha
- introduced localization using hyperdiary.json; date format and month names so far
- added tiddlers for month (calendar) and year overview with hyperlinks
- Diary supports iteration by year/month
- make docs work
0.5.0 (2019-11-06)¶
- removed EntryType, refactored iteration, primarily passing Diary instances around
- fix bug when an ID is followed by a bracket )
- only line entries are allowed, no more dicts
0.4.0 (2019-10-30)¶
- full type annotations added for package
- linting and type checking in CI
- EntryTypes Dict and DictLine are deprecated and will be removed in 0.5 (check issues a warning)
0.3.2 (2019-10-17)¶
- fix linter configuration (and activate it)
- make all hyperdiary source files PEP8 conform
- set up bumpversion config
0.3.1 (2019-07-03)¶
- open date ranges iterate until yesterday, not today
- fix loading hyperdiary.json without expected field
0.3.0 (2019-06-19)¶
- Expected date ranges for check subcommand can be specified
- subcommand for export to tiddlywiki
- Tests for various output formats
0.2.0 (2019-06-12)¶
- stats subcommand can be invoked for all entries
- Rename tiddlywiki subcommand to tiddlers for different future usage
- Integrate Travis CI for automated testing
- Add basic tests
- Refactor diary/entry passing to subcommands
0.1.2 (2019-06-11)¶
- Fix htmlfolder subcommand by packaging picnic.min.css
- Fix view subcommand by using correct relative import
- Avoid deprecation warning in stats subcommand by using yaml.SafeLoader
0.1.1 (2019-04-29)¶
- Fix setup
0.1.0 (2019-04-28)¶
- First release on PyPI
- Import from fossil