From b8313e0776b62049a6250ddb230c57e3617f8166 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Thu, 8 Feb 2018 23:28:59 -0800 Subject: [PATCH 01/38] Add Docker files --- Dockerfile | 9 +++++++++ README.md | 11 +++++++++++ docker-compose.yml | 7 +++++++ requirements.txt | 2 ++ 4 files changed, 29 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 requirements.txt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..78104ad --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3 + +RUN mkdir /code +ADD requirements.txt /code/ +WORKDIR /code +RUN pip install -r requirements.txt +ADD . /code/ + +CMD python generator.py diff --git a/README.md b/README.md index cd9523b..33bb171 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,17 @@ user manual. Thanks to [tldr.jsx][4] for your great CSS! +### Build + +If you have python 3 and the [required packages](requirements.txt): + + python generator.py + +Or use Docker to create an environment and build: + + docker-compose up + + [1]: http://kapeli.com/dash [2]: http://zealdocs.org/ [3]: https://github.com/tldr-pages/tldr diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..442f526 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +version: '2' + +services: + builder: + build: . + volumes: + - .:/code diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..746027a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +requests +markdown2 From dad15f16ba2608834e6447e6400e3123f735a5b2 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Fri, 9 Feb 2018 11:41:37 -0800 Subject: [PATCH 02/38] Update styles - support inline code elements - add bottom margin to page - remove unused styles --- static/style.css | 46 +++++++--------------------------------------- 1 file changed, 7 insertions(+), 39 deletions(-) diff --git a/static/style.css b/static/style.css index 9ce4c6d..ebe1d1b 100644 --- a/static/style.css +++ b/static/style.css @@ -7,41 +7,8 @@ body { background: #FEFEFE; color: #151515; } -.github-corner { - border: 0; - fill: #FEFEFE; - position: fixed; - right: 0; - top: 0; - z-index: 99; - padding: 0.5em; } - @media only screen and (min-device-width: 1024px) and (min-device-height: 728px) { - .github-corner { - padding: 0.2em; } } - -#tldr #search-bar { - font-size: 1.5em; - background-color: #151515; - color: #FEFEFE; - padding: 0.5em; - position: fixed; - top: 0; - left: 0; - width: 100%; } - #tldr #search-bar * { - font-family: "Source Code Pro", courier new, courier; } - #tldr #search-bar input, #tldr #search-bar input:focus { - border: none; - outline: none; - background-color: #151515; - color: #FEFEFE; } - @media only screen and (orientation: landscape) { - #tldr #search-bar { - font-size: 2em; } } - @media only screen and (min-device-width: 1024px) and (min-device-height: 728px) { - #tldr #search-bar { - font-size: 1em; } } #tldr #page { + margin-bottom: 4em; font-size: 1.25em;} #tldr #page p { margin: 0; } @@ -54,9 +21,12 @@ body { font-family: "Source Code Pro", courier new, courier; background-color: #f2f2f2; color: #212121; - display: block; - padding: 0.55em 1.25em; + display: inline-block; + padding: 0.25em 0.5em; margin: 0; } + #tldr #page > p code { + display: block; + padding: 0.55em 1.25em; } #tldr #page ul { list-style: none; padding: 0 !important; @@ -67,10 +37,8 @@ body { @media only screen and (min-device-width: 1024px) { #tldr #page { font-size: 1em; } - #tldr #page code { + #tldr #page > p code { padding-left: 3em; } #tldr #page ul li:before { content: "*"; padding: 0 12px; } } - -/*# sourceMappingURL=index.css.map */ From 8bac0b3f4a3909f637e5103edbf2283a27776fd6 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Fri, 9 Feb 2018 11:51:52 -0800 Subject: [PATCH 03/38] Add support for online redirection - https://kapeli.com/docsets#onlineRedirection --- generator.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/generator.py b/generator.py index d4076ad..664cce2 100755 --- a/generator.py +++ b/generator.py @@ -2,8 +2,18 @@ import requests as req, zipfile, io, markdown2 as md, sqlite3, os, shutil, tarfile -html_tmpl = """
%content%
""" +html_tmpl = """ + + + + +
+
{content}
+
+ +""" +online_url = "https://github.com/tldr-pages/tldr/blob/master/pages" doc_source = "https://github.com/tldr-pages/tldr/archive/master.zip" docset_path = "tldrpages.docset" doc_path_contents = docset_path + "/Contents/" @@ -54,7 +64,7 @@ else: cur.execute('INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (?,?,?)', (cmd_name, 'Command', sub_dir+'/'+cmd_name+".html")) doc = markdowner.convert(archive.read(path)) - doc = html_tmpl.replace("%content%", doc) + doc = html_tmpl.format(url=online_url+'/'+sub_dir+'/'+cmd_name, content=doc) with open(os.path.join(doc_path, path[len(doc_pref)+1:].replace(".md", ".html")), "wb") as html: html.write(doc.encode("utf-8")) db.commit() @@ -62,7 +72,7 @@ # Generate tldr pages index.html with open(os.path.join(doc_path, "index.html"), "w+") as html: - html.write('

TLDR pages Docset


powered by tldr-pages.github.io/') + html.write('

TLDR pages Docset


powered by tldr-pages.github.io/') for dir in os.listdir(doc_path): if os.path.isdir(os.path.join(doc_path, dir)): html.write("

%s

    " % dir) From f6ad4bb7b7b6d7f2b24820febca31f602f465d80 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Mon, 12 Feb 2018 09:02:46 -0800 Subject: [PATCH 04/38] Ensure alphabetical order on index page --- generator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generator.py b/generator.py index 664cce2..d487155 100755 --- a/generator.py +++ b/generator.py @@ -73,10 +73,10 @@ # Generate tldr pages index.html with open(os.path.join(doc_path, "index.html"), "w+") as html: html.write('

    TLDR pages Docset


    powered by tldr-pages.github.io/') - for dir in os.listdir(doc_path): + for dir in sorted(os.listdir(doc_path)): if os.path.isdir(os.path.join(doc_path, dir)): html.write("

    %s

      " % dir) - html.writelines(['
    • %s
    • ' % (dir, f, f[:-5]) for f in os.listdir(os.path.join(doc_path, dir))]) + html.writelines(['
    • %s
    • ' % (dir, f, f[:-5]) for f in sorted(os.listdir(os.path.join(doc_path, dir)))]) html.write("
    ") html.write('') From 23328694588f2ea8882daa9624e81ab8b9bbf0fa Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Fri, 9 Feb 2018 16:27:24 -0800 Subject: [PATCH 05/38] Fix encoding issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - e.g. isn’t -> isn’t --- generator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generator.py b/generator.py index d487155..67d8a46 100755 --- a/generator.py +++ b/generator.py @@ -4,6 +4,7 @@ html_tmpl = """ + @@ -72,7 +73,7 @@ # Generate tldr pages index.html with open(os.path.join(doc_path, "index.html"), "w+") as html: - html.write('

    TLDR pages Docset


    powered by tldr-pages.github.io/') + html.write('

    TLDR pages Docset


    powered by tldr-pages.github.io/') for dir in sorted(os.listdir(doc_path)): if os.path.isdir(os.path.join(doc_path, dir)): html.write("

    %s

      " % dir) From 4beeeab7d8bfa4c31d4781c663c83f7deacde688 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Mon, 12 Feb 2018 09:29:25 -0800 Subject: [PATCH 06/38] Add title and table of contents to index page - https://kapeli.com/docsets#tableofcontents --- generator.py | 4 ++-- static/Info.plist | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/generator.py b/generator.py index 67d8a46..c565210 100755 --- a/generator.py +++ b/generator.py @@ -73,10 +73,10 @@ # Generate tldr pages index.html with open(os.path.join(doc_path, "index.html"), "w+") as html: - html.write('

      TLDR pages Docset


      powered by tldr-pages.github.io/') + html.write('TLDR pages

      TLDR pages


      powered by tldr-pages.github.io/') for dir in sorted(os.listdir(doc_path)): if os.path.isdir(os.path.join(doc_path, dir)): - html.write("

      %s

        " % dir) + html.write('

        {name}

          '.format(name=dir)) html.writelines(['
        • %s
        • ' % (dir, f, f[:-5]) for f in sorted(os.listdir(os.path.join(doc_path, dir)))]) html.write("
        ") html.write('') diff --git a/static/Info.plist b/static/Info.plist index 65f5a2a..e7e31cc 100644 --- a/static/Info.plist +++ b/static/Info.plist @@ -12,5 +12,7 @@ dashIndexFilePath index.html + DashDocSetFamily + dashtoc From ee201b454a2a70f9f0d58aefa447cb3d1fdada0d Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Mon, 12 Feb 2018 14:18:51 -0800 Subject: [PATCH 07/38] Style curly brackets as colored text - does not handle nested brackets e.g. `{{a {{b}} c}}`, but did not find any instances of this in tldr pages close #4 --- generator.py | 2 ++ static/style.css | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/generator.py b/generator.py index c565210..3e38030 100755 --- a/generator.py +++ b/generator.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import requests as req, zipfile, io, markdown2 as md, sqlite3, os, shutil, tarfile +import re html_tmpl = """ @@ -65,6 +66,7 @@ else: cur.execute('INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (?,?,?)', (cmd_name, 'Command', sub_dir+'/'+cmd_name+".html")) doc = markdowner.convert(archive.read(path)) + doc = re.sub(r'{{(.*?)}}', r'\1', doc) doc = html_tmpl.format(url=online_url+'/'+sub_dir+'/'+cmd_name, content=doc) with open(os.path.join(doc_path, path[len(doc_pref)+1:].replace(".md", ".html")), "wb") as html: html.write(doc.encode("utf-8")) diff --git a/static/style.css b/static/style.css index ebe1d1b..72943c4 100644 --- a/static/style.css +++ b/static/style.css @@ -7,6 +7,10 @@ body { background: #FEFEFE; color: #151515; } +code em { + color: lightseagreen; + font-style: normal; } + #tldr #page { margin-bottom: 4em; font-size: 1.25em;} From 64c23e9449e921fdbd11ec9864861e0f97628d98 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Mon, 12 Feb 2018 14:29:02 -0800 Subject: [PATCH 08/38] Update styles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fix font inheriting for elements inside a `code` element - use endash (–) instead of asterisk (*) for list items - match left padding for description and code snippets, also improves wrapping - use same font size for small and large screens. before, fonts were larger for small screens - add fallback generic fonts --- static/style.css | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/static/style.css b/static/style.css index 72943c4..9424017 100644 --- a/static/style.css +++ b/static/style.css @@ -1,8 +1,6 @@ -* { - font-family: Helvetica Neue, Helvetica; - font-size: 1em; } - body { + font-family: Helvetica Neue, Helvetica, sans-serif; + font-size: 16px; margin: 0; background: #FEFEFE; color: #151515; } @@ -12,8 +10,7 @@ code em { font-style: normal; } #tldr #page { - margin-bottom: 4em; - font-size: 1.25em;} + margin-bottom: 4em; } #tldr #page p { margin: 0; } #tldr #page h1 { @@ -22,7 +19,7 @@ code em { #tldr #page blockquote { margin: 0 0.55em; } #tldr #page code { - font-family: "Source Code Pro", courier new, courier; + font-family: "Source Code Pro", courier new, courier, monospace; background-color: #f2f2f2; color: #212121; display: inline-block; @@ -30,7 +27,7 @@ code em { margin: 0; } #tldr #page > p code { display: block; - padding: 0.55em 1.25em; } + padding: 0.55em; } #tldr #page ul { list-style: none; padding: 0 !important; @@ -39,10 +36,11 @@ code em { padding: 0.5em 0.55em; line-height: 1.1; } @media only screen and (min-device-width: 1024px) { - #tldr #page { - font-size: 1em; } #tldr #page > p code { padding-left: 3em; } + #tldr #page ul li { + padding-left: 3em; } #tldr #page ul li:before { - content: "*"; - padding: 0 12px; } } + content: "–"; + position: absolute; + margin-left: -1.5em; } } From 2db7fab28b112937158a389fb389966067b2313d Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Mon, 12 Feb 2018 15:07:57 -0800 Subject: [PATCH 09/38] Fix online redirection --- generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator.py b/generator.py index 3e38030..10e417c 100755 --- a/generator.py +++ b/generator.py @@ -67,7 +67,7 @@ cur.execute('INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (?,?,?)', (cmd_name, 'Command', sub_dir+'/'+cmd_name+".html")) doc = markdowner.convert(archive.read(path)) doc = re.sub(r'{{(.*?)}}', r'\1', doc) - doc = html_tmpl.format(url=online_url+'/'+sub_dir+'/'+cmd_name, content=doc) + doc = html_tmpl.format(url=online_url+'/'+sub_dir+'/'+cmd_name+'.md', content=doc) with open(os.path.join(doc_path, path[len(doc_pref)+1:].replace(".md", ".html")), "wb") as html: html.write(doc.encode("utf-8")) db.commit() From c926e30b258f47c06e29ddc53c981c043b6d694e Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Mon, 12 Feb 2018 15:23:21 -0800 Subject: [PATCH 10/38] Fix text with underscores - day_of_week now works, previously was rendered as dayofweek with "of" being italicized - https://github.com/trentm/python-markdown2/wiki/code-friendly --- generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generator.py b/generator.py index 10e417c..bdb2b6c 100755 --- a/generator.py +++ b/generator.py @@ -48,7 +48,7 @@ cur.execute('CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path);') # Generate tldr pages to HTML documents -markdowner = md.Markdown() +markdowner = md.Markdown(extras=["code-friendly"]) with zipfile.ZipFile(io.BytesIO(r.content), "r") as archive: for path in archive.namelist(): if path.startswith(doc_pref) and path.endswith(".md"): From fc8573f22abc70f829211c08e6c6cf91033a68d6 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Mon, 12 Feb 2018 15:58:58 -0800 Subject: [PATCH 11/38] Bump version --- static/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/Info.plist b/static/Info.plist index e7e31cc..d19eb68 100644 --- a/static/Info.plist +++ b/static/Info.plist @@ -3,7 +3,7 @@ CFBundleIdentifier - TLDR pages 0.0.2.8 + TLDR pages 0.0.3.0 CFBundleName TLDR pages DocSetPlatformFamily From e97ee73d8db18e337075d522beffabae1d44682e Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Wed, 14 Feb 2018 10:17:43 -0800 Subject: [PATCH 12/38] Use COPY instead of ADD in Dockerfile - COPY is less magical and is recommended by Docker --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 78104ad..4ffa7fe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ FROM python:3 RUN mkdir /code -ADD requirements.txt /code/ +COPY requirements.txt /code/ WORKDIR /code RUN pip install -r requirements.txt -ADD . /code/ +COPY . /code/ CMD python generator.py From 27ff4c88f4a859b2fee3e19247178000d95ed8e5 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Tue, 3 Apr 2018 20:48:07 -0700 Subject: [PATCH 13/38] Bump version --- static/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/Info.plist b/static/Info.plist index d19eb68..0f25798 100644 --- a/static/Info.plist +++ b/static/Info.plist @@ -3,7 +3,7 @@ CFBundleIdentifier - TLDR pages 0.0.3.0 + TLDR pages 0.0.3.1 CFBundleName TLDR pages DocSetPlatformFamily From 1aa47fe3a8808cb66f4a24ba30df88b709810523 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Thu, 28 Mar 2019 06:34:56 -0400 Subject: [PATCH 14/38] Change path matcher to handle new "pages" folders in tldr-pages repo --- generator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generator.py b/generator.py index bdb2b6c..c82e48e 100755 --- a/generator.py +++ b/generator.py @@ -21,7 +21,7 @@ doc_path_contents = docset_path + "/Contents/" doc_path_resources = docset_path + "/Contents/Resources/" doc_path = docset_path + "/Contents/Resources/Documents/" -doc_pref = "tldr-master/pages" +doc_pref = "tldr-master/pages/" if os.path.exists(doc_path): try: shutil.rmtree(doc_path) @@ -53,7 +53,7 @@ for path in archive.namelist(): if path.startswith(doc_pref) and path.endswith(".md"): cmd_name = path[path.rfind("/")+1:-3] - sub_dir = path[len(doc_pref)+1:path.rfind("/")] + sub_dir = path[len(doc_pref):path.rfind("/")] sub_path = os.path.join(doc_path, sub_dir) if not os.path.exists(sub_path): try: os.mkdir(sub_path) @@ -68,7 +68,7 @@ doc = markdowner.convert(archive.read(path)) doc = re.sub(r'{{(.*?)}}', r'\1', doc) doc = html_tmpl.format(url=online_url+'/'+sub_dir+'/'+cmd_name+'.md', content=doc) - with open(os.path.join(doc_path, path[len(doc_pref)+1:].replace(".md", ".html")), "wb") as html: + with open(os.path.join(doc_path, path[len(doc_pref):].replace(".md", ".html")), "wb") as html: html.write(doc.encode("utf-8")) db.commit() db.close() From 3af791c13d08cfa37071839973c37aa5d72fa987 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Thu, 28 Mar 2019 06:35:15 -0400 Subject: [PATCH 15/38] Bump version --- static/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/Info.plist b/static/Info.plist index 0f25798..9c9c72f 100644 --- a/static/Info.plist +++ b/static/Info.plist @@ -3,7 +3,7 @@ CFBundleIdentifier - TLDR pages 0.0.3.1 + TLDR pages 0.0.3.2 CFBundleName TLDR pages DocSetPlatformFamily From db381dd303585f19871959a9d77fd9d840aeddc3 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Sun, 26 Apr 2020 20:42:50 -0400 Subject: [PATCH 16/38] Bump version --- static/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/Info.plist b/static/Info.plist index 9c9c72f..bf0dea7 100644 --- a/static/Info.plist +++ b/static/Info.plist @@ -3,7 +3,7 @@ CFBundleIdentifier - TLDR pages 0.0.3.2 + TLDR pages 0.0.3.3 CFBundleName TLDR pages DocSetPlatformFamily From 801ed51a15e5481c936eb6c9c78d14075d5b9104 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Wed, 21 Oct 2020 02:55:58 -0400 Subject: [PATCH 17/38] Bump version --- static/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/Info.plist b/static/Info.plist index bf0dea7..5792b07 100644 --- a/static/Info.plist +++ b/static/Info.plist @@ -3,7 +3,7 @@ CFBundleIdentifier - TLDR pages 0.0.3.3 + TLDR pages 0.0.3.4 CFBundleName TLDR pages DocSetPlatformFamily From c7ed388ea4196b38c2f2ddfb65ac1f415a41e2f5 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Sun, 1 May 2022 23:34:42 +0800 Subject: [PATCH 18/38] Bump version --- static/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/Info.plist b/static/Info.plist index 5792b07..ca0014a 100644 --- a/static/Info.plist +++ b/static/Info.plist @@ -3,7 +3,7 @@ CFBundleIdentifier - TLDR pages 0.0.3.4 + TLDR pages 0.0.3.5 CFBundleName TLDR pages DocSetPlatformFamily From 05b1eb70dc77a24fd9ac20ddb51c41731ac964e3 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Tue, 8 Nov 2022 01:00:30 -0500 Subject: [PATCH 19/38] Bump version --- static/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/Info.plist b/static/Info.plist index ca0014a..64745d4 100644 --- a/static/Info.plist +++ b/static/Info.plist @@ -3,7 +3,7 @@ CFBundleIdentifier - TLDR pages 0.0.3.5 + TLDR pages 0.0.3.6 CFBundleName TLDR pages DocSetPlatformFamily From 54e93a2e6bb5cc18a045c94f124f834808684916 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Wed, 18 Oct 2023 01:41:04 -0400 Subject: [PATCH 20/38] Fix for tldr pages switching from master to main See https://github.com/Moddus/tldr-python-dash-docset/pull/7 for more details. --- generator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generator.py b/generator.py index c82e48e..4b057c5 100755 --- a/generator.py +++ b/generator.py @@ -15,13 +15,13 @@ """ -online_url = "https://github.com/tldr-pages/tldr/blob/master/pages" -doc_source = "https://github.com/tldr-pages/tldr/archive/master.zip" +online_url = "https://github.com/tldr-pages/tldr/blob/main/pages" +doc_source = "https://github.com/tldr-pages/tldr/archive/refs/heads/main.zip" docset_path = "tldrpages.docset" doc_path_contents = docset_path + "/Contents/" doc_path_resources = docset_path + "/Contents/Resources/" doc_path = docset_path + "/Contents/Resources/Documents/" -doc_pref = "tldr-master/pages/" +doc_pref = "tldr-main/pages/" if os.path.exists(doc_path): try: shutil.rmtree(doc_path) From 6a24af7ea7c6584c9393082106a261bda4e8226d Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Wed, 18 Oct 2023 01:59:13 -0400 Subject: [PATCH 21/38] Update readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 33bb171..beff31b 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ user manual. Thanks to [tldr.jsx][4] for your great CSS! +### This is a fork + +The original author of this project, [Moddus](https://github.com/Moddus/tldr-python-dash-docset), appears to have abandoned it. This fork contains some [bug fixes and small improvements](https://github.com/Moddus/tldr-python-dash-docset/pull/5) to the original. + ### Build If you have python 3 and the [required packages](requirements.txt): From 3f6cb04efc2b8212d7476f2971497d3f78ea8f8e Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Wed, 18 Oct 2023 01:59:51 -0400 Subject: [PATCH 22/38] Bump version --- static/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/Info.plist b/static/Info.plist index 64745d4..1f512f4 100644 --- a/static/Info.plist +++ b/static/Info.plist @@ -3,7 +3,7 @@ CFBundleIdentifier - TLDR pages 0.0.3.6 + TLDR pages 0.0.3.7 CFBundleName TLDR pages DocSetPlatformFamily From 2be92e4dfc1284d2d8ff720f79a1a07cae987f19 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Mon, 30 Oct 2023 00:59:48 -0400 Subject: [PATCH 23/38] Add github action for docset generation, WIP --- .github/workflows/update-docset.yml | 51 +++++++++++++++++++++++++++++ static/Info.plist | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/update-docset.yml diff --git a/.github/workflows/update-docset.yml b/.github/workflows/update-docset.yml new file mode 100644 index 0000000..6e12dc3 --- /dev/null +++ b/.github/workflows/update-docset.yml @@ -0,0 +1,51 @@ +name: Monthly Update + +on: + schedule: + - cron: '0 0 1 * *' + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + container: docker/docker:latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set version number + run: sed -i '' "s/YYYY-MM-DD/$(date -u +"%Y-%m-%d")/" static/Info.plist + - name: Build docset + run: docker compose up + + create-branch: + needs: build + runs-on: ubuntu-latest + steps: + - name: Sync repo + run: gh repo sync cvn/Dash-User-Contributions -b master --force + env: + GITHUB_TOKEN: ${{ secrets.DASH_REPO_TOKEN }} + - name: Checkout code + uses: actions/checkout@v4 + with: + repository: cvn/Dash-User-Contributions + token: ${{ secrets.DASH_REPO_TOKEN }} + path: Dash-User-Contributions + - name: Create brach + run: | + cd Dash-User-Contributions + git checkout -b tldr-pages-update + git push origin tldr-pages-update + - name: Check directory + run: pwd + - name: Update version number in docset.json + run: | + sed -i 's/"version": ".*"/"version": "$(date +%Y-%m-%d)"/' Dash-User-Contributions/docsets/tldr/docset.json + - name: Move docset + run: mv tldr_pages.tgz Dash-User-Contributions/docsets/tldr/ + - name: Commit changes + run: | + cd Dash-User-Contributions + git add --all . + git commit -m "Update TLDR pages docset to $(date +%Y-%m-%d)" + git push \ No newline at end of file diff --git a/static/Info.plist b/static/Info.plist index 1f512f4..61d3ffa 100644 --- a/static/Info.plist +++ b/static/Info.plist @@ -3,7 +3,7 @@ CFBundleIdentifier - TLDR pages 0.0.3.7 + TLDR pages YYYY-MM-DD CFBundleName TLDR pages DocSetPlatformFamily From 4a8df0e5ade588cc0ab1974c2b07ced7565ec000 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Mon, 30 Oct 2023 01:17:03 -0400 Subject: [PATCH 24/38] ci: docker is installed on github runners already --- .github/workflows/update-docset.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/update-docset.yml b/.github/workflows/update-docset.yml index 6e12dc3..3645bec 100644 --- a/.github/workflows/update-docset.yml +++ b/.github/workflows/update-docset.yml @@ -8,7 +8,6 @@ on: jobs: build: runs-on: ubuntu-latest - container: docker/docker:latest steps: - name: Checkout code uses: actions/checkout@v4 From 0158cbb36111e2f34effdb21508d8be948bf395c Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Mon, 30 Oct 2023 01:39:21 -0400 Subject: [PATCH 25/38] ci: use variable for the date string --- .github/workflows/update-docset.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update-docset.yml b/.github/workflows/update-docset.yml index 3645bec..eb20b93 100644 --- a/.github/workflows/update-docset.yml +++ b/.github/workflows/update-docset.yml @@ -5,6 +5,9 @@ on: - cron: '0 0 1 * *' workflow_dispatch: +env: + new_version: $(date -u +"%Y-%m-%d") + jobs: build: runs-on: ubuntu-latest @@ -12,7 +15,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Set version number - run: sed -i '' "s/YYYY-MM-DD/$(date -u +"%Y-%m-%d")/" static/Info.plist + run: sed -i '' "s/YYYY-MM-DD/$new_version/" static/Info.plist - name: Build docset run: docker compose up @@ -39,12 +42,12 @@ jobs: run: pwd - name: Update version number in docset.json run: | - sed -i 's/"version": ".*"/"version": "$(date +%Y-%m-%d)"/' Dash-User-Contributions/docsets/tldr/docset.json + sed -i 's/"version": ".*"/"version": "$new_version"/' Dash-User-Contributions/docsets/tldr/docset.json - name: Move docset run: mv tldr_pages.tgz Dash-User-Contributions/docsets/tldr/ - name: Commit changes run: | cd Dash-User-Contributions git add --all . - git commit -m "Update TLDR pages docset to $(date +%Y-%m-%d)" - git push \ No newline at end of file + git commit -m "Update TLDR pages docset to $new_version" + git push From 88a1ddcbe57ef14233175fc1656487942a4a3047 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Mon, 30 Oct 2023 01:40:30 -0400 Subject: [PATCH 26/38] ci: change sed syntax from bsd to linux --- .github/workflows/update-docset.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-docset.yml b/.github/workflows/update-docset.yml index eb20b93..3b2b79c 100644 --- a/.github/workflows/update-docset.yml +++ b/.github/workflows/update-docset.yml @@ -15,7 +15,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - name: Set version number - run: sed -i '' "s/YYYY-MM-DD/$new_version/" static/Info.plist + run: sed -i "s/YYYY-MM-DD/$new_version/" static/Info.plist - name: Build docset run: docker compose up From 6f1ad65e3bec9a2c8c412de18f02fd5189ca38f0 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Mon, 30 Oct 2023 02:00:33 -0400 Subject: [PATCH 27/38] ci: files are not shared between jobs by default, so just use one job --- .github/workflows/update-docset.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/update-docset.yml b/.github/workflows/update-docset.yml index 3b2b79c..93d2307 100644 --- a/.github/workflows/update-docset.yml +++ b/.github/workflows/update-docset.yml @@ -19,10 +19,6 @@ jobs: - name: Build docset run: docker compose up - create-branch: - needs: build - runs-on: ubuntu-latest - steps: - name: Sync repo run: gh repo sync cvn/Dash-User-Contributions -b master --force env: From b3793edfb6c74fc8bf28c6a784d1357d578e353f Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Mon, 30 Oct 2023 02:08:51 -0400 Subject: [PATCH 28/38] ci: github runner does not execute shell commands, use alternate env var --- .github/workflows/update-docset.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-docset.yml b/.github/workflows/update-docset.yml index 93d2307..52ada32 100644 --- a/.github/workflows/update-docset.yml +++ b/.github/workflows/update-docset.yml @@ -5,13 +5,12 @@ on: - cron: '0 0 1 * *' workflow_dispatch: -env: - new_version: $(date -u +"%Y-%m-%d") - jobs: build: runs-on: ubuntu-latest steps: + - name: Create version environment variable + run: echo "new_version=$(date -u +%Y-%m-%d)" >> $GITHUB_ENV - name: Checkout code uses: actions/checkout@v4 - name: Set version number From 77f38cddd8701bb1829936e11a40c8348be40ab2 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Mon, 30 Oct 2023 02:21:08 -0400 Subject: [PATCH 29/38] ci: ensure branch is always updated --- .github/workflows/update-docset.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-docset.yml b/.github/workflows/update-docset.yml index 52ada32..9ed7eb1 100644 --- a/.github/workflows/update-docset.yml +++ b/.github/workflows/update-docset.yml @@ -32,7 +32,7 @@ jobs: run: | cd Dash-User-Contributions git checkout -b tldr-pages-update - git push origin tldr-pages-update + git push --force origin tldr-pages-update - name: Check directory run: pwd - name: Update version number in docset.json From 481d75c1e155f7a87e3a7aada83e80fae59113b6 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Tue, 31 Oct 2023 01:14:24 -0400 Subject: [PATCH 30/38] ci: fix author identity unknown error Bot account details from https://github.com/actions/checkout/issues/13#issuecomment-724415212 --- .github/workflows/update-docset.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/update-docset.yml b/.github/workflows/update-docset.yml index 9ed7eb1..f1a9dd6 100644 --- a/.github/workflows/update-docset.yml +++ b/.github/workflows/update-docset.yml @@ -43,6 +43,8 @@ jobs: - name: Commit changes run: | cd Dash-User-Contributions + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git add --all . git commit -m "Update TLDR pages docset to $new_version" git push From 64b2e66a05101a2f0df4ddcffae3ac8d57236c01 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Tue, 31 Oct 2023 01:15:48 -0400 Subject: [PATCH 31/38] ci: fix variable expansion --- .github/workflows/update-docset.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-docset.yml b/.github/workflows/update-docset.yml index f1a9dd6..f3e245c 100644 --- a/.github/workflows/update-docset.yml +++ b/.github/workflows/update-docset.yml @@ -37,7 +37,7 @@ jobs: run: pwd - name: Update version number in docset.json run: | - sed -i 's/"version": ".*"/"version": "$new_version"/' Dash-User-Contributions/docsets/tldr/docset.json + sed -i "s/\"version\": \".*\"/\"version\": \"$new_version\"/" Dash-User-Contributions/docsets/tldr/docset.json - name: Move docset run: mv tldr_pages.tgz Dash-User-Contributions/docsets/tldr/ - name: Commit changes From fb0e150e4299a7f433f3341cfb4d28c45daa9f5b Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Tue, 31 Oct 2023 01:28:01 -0400 Subject: [PATCH 32/38] ci: refactor git commands for readability --- .github/workflows/update-docset.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/update-docset.yml b/.github/workflows/update-docset.yml index f3e245c..2276efb 100644 --- a/.github/workflows/update-docset.yml +++ b/.github/workflows/update-docset.yml @@ -28,13 +28,6 @@ jobs: repository: cvn/Dash-User-Contributions token: ${{ secrets.DASH_REPO_TOKEN }} path: Dash-User-Contributions - - name: Create brach - run: | - cd Dash-User-Contributions - git checkout -b tldr-pages-update - git push --force origin tldr-pages-update - - name: Check directory - run: pwd - name: Update version number in docset.json run: | sed -i "s/\"version\": \".*\"/\"version\": \"$new_version\"/" Dash-User-Contributions/docsets/tldr/docset.json @@ -45,6 +38,7 @@ jobs: cd Dash-User-Contributions git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git checkout -b tldr-pages-update git add --all . git commit -m "Update TLDR pages docset to $new_version" - git push + git push --force origin tldr-pages-update From 1b8b6bb410811d6cb079340ebaaf43f4e69aa306 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Tue, 31 Oct 2023 01:32:07 -0400 Subject: [PATCH 33/38] ci: whitespace, add comments --- .github/workflows/update-docset.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-docset.yml b/.github/workflows/update-docset.yml index 2276efb..85f0f89 100644 --- a/.github/workflows/update-docset.yml +++ b/.github/workflows/update-docset.yml @@ -11,28 +11,41 @@ jobs: steps: - name: Create version environment variable run: echo "new_version=$(date -u +%Y-%m-%d)" >> $GITHUB_ENV + + + # Build docset + - name: Checkout code uses: actions/checkout@v4 + - name: Set version number run: sed -i "s/YYYY-MM-DD/$new_version/" static/Info.plist + - name: Build docset run: docker compose up - - name: Sync repo + + # Create PR + + - name: Sync contributions repo run: gh repo sync cvn/Dash-User-Contributions -b master --force env: GITHUB_TOKEN: ${{ secrets.DASH_REPO_TOKEN }} + - name: Checkout code uses: actions/checkout@v4 with: repository: cvn/Dash-User-Contributions token: ${{ secrets.DASH_REPO_TOKEN }} path: Dash-User-Contributions + - name: Update version number in docset.json run: | sed -i "s/\"version\": \".*\"/\"version\": \"$new_version\"/" Dash-User-Contributions/docsets/tldr/docset.json + - name: Move docset run: mv tldr_pages.tgz Dash-User-Contributions/docsets/tldr/ + - name: Commit changes run: | cd Dash-User-Contributions From 5aa332aabdfa56a0ee9fee3301d9a9745a658921 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Tue, 31 Oct 2023 01:50:31 -0400 Subject: [PATCH 34/38] ci: rename a few things --- .github/workflows/update-docset.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-docset.yml b/.github/workflows/update-docset.yml index 85f0f89..1bb02c3 100644 --- a/.github/workflows/update-docset.yml +++ b/.github/workflows/update-docset.yml @@ -1,4 +1,4 @@ -name: Monthly Update +name: Update Docset on: schedule: @@ -51,7 +51,7 @@ jobs: cd Dash-User-Contributions git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git checkout -b tldr-pages-update + git checkout -b tldr-update git add --all . git commit -m "Update TLDR pages docset to $new_version" - git push --force origin tldr-pages-update + git push --force origin tldr-update From 1c772c87b9d30f4c526cf65d5f2140e2bfb2b71f Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Tue, 31 Oct 2023 02:25:22 -0400 Subject: [PATCH 35/38] ci: add step to create PR --- .github/workflows/update-docset.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/update-docset.yml b/.github/workflows/update-docset.yml index 1bb02c3..d918059 100644 --- a/.github/workflows/update-docset.yml +++ b/.github/workflows/update-docset.yml @@ -55,3 +55,10 @@ jobs: git add --all . git commit -m "Update TLDR pages docset to $new_version" git push --force origin tldr-update + + - name: Create pull request to upstream + run: | + cd Dash-User-Contributions + gh pr create --head tldr-update --title "Update TLDR pages docset to $new_version" --body "This is an automated update created by [a workflow](https://github.com/cvn/tldr-python-dash-docset/actions/workflows/update-docset.yml)." + env: + GITHUB_TOKEN: ${{ secrets.DASH_REPO_TOKEN }} From 658bb9602791a757dd7962f8135ed6494752c22a Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Tue, 31 Oct 2023 03:13:35 -0400 Subject: [PATCH 36/38] ci: set upstream repo, break command into multiple lines --- .github/workflows/update-docset.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-docset.yml b/.github/workflows/update-docset.yml index d918059..c3d52c1 100644 --- a/.github/workflows/update-docset.yml +++ b/.github/workflows/update-docset.yml @@ -59,6 +59,10 @@ jobs: - name: Create pull request to upstream run: | cd Dash-User-Contributions - gh pr create --head tldr-update --title "Update TLDR pages docset to $new_version" --body "This is an automated update created by [a workflow](https://github.com/cvn/tldr-python-dash-docset/actions/workflows/update-docset.yml)." + gh pr create \ + --repo Kapeli/Dash-User-Contributions \ + --head cvn/Dash-User-Contributions:tldr-update \ + --title "Update TLDR pages docset to $new_version" \ + --body "This is an automated update created by [a workflow](https://github.com/cvn/tldr-python-dash-docset/actions/workflows/update-docset.yml)." env: GITHUB_TOKEN: ${{ secrets.DASH_REPO_TOKEN }} From 61ed3e54c5fddb65c6782a6bc8fadaf743d59b07 Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Tue, 31 Oct 2023 23:54:49 -0400 Subject: [PATCH 37/38] ci: fix PR command --- .github/workflows/update-docset.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-docset.yml b/.github/workflows/update-docset.yml index c3d52c1..733051a 100644 --- a/.github/workflows/update-docset.yml +++ b/.github/workflows/update-docset.yml @@ -61,7 +61,7 @@ jobs: cd Dash-User-Contributions gh pr create \ --repo Kapeli/Dash-User-Contributions \ - --head cvn/Dash-User-Contributions:tldr-update \ + --head cvn:tldr-update \ --title "Update TLDR pages docset to $new_version" \ --body "This is an automated update created by [a workflow](https://github.com/cvn/tldr-python-dash-docset/actions/workflows/update-docset.yml)." env: From 1988d4a82a36ed18e798d180c585fff6caf712fe Mon Sep 17 00:00:00 2001 From: Chad von Nau Date: Mon, 6 Nov 2023 11:41:24 -0500 Subject: [PATCH 38/38] Update readme --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index beff31b..bb22893 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,11 @@ If you have python 3 and the [required packages](requirements.txt): Or use Docker to create an environment and build: - docker-compose up + docker compose up + +### Updating Dash + +This repo has [a workflow](https://github.com/cvn/tldr-python-dash-docset/actions/workflows/update-docset.yml) that regularly updates the docset in Dash. [1]: http://kapeli.com/dash