Commit 4b3dde9e authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

Improve Api linking with special markdown hook

parent b4d90b76
{"kdeclarative": "https://api.kde.org/frameworks/kdeclarative/html/", "ki18n": "https://api.kde.org/frameworks/ki18n/html/", "kcoreaddons": "https://api.kde.org/frameworks/kcoreaddons/html/", "kio": "https://api.kde.org/frameworks/kio/html/", "kxmlgui": "https://api.kde.org/frameworks/kXmlGui/html/", "kconfigwidgets": "https://api.kde.org/frameworks/kconfigwidgets/html/", "kwidgetsaddons": "https://api.kde.org/frameworks/kwidgetsaddons/html/", "qtquickcontrols": "https://doc.qt.io/qt-5/"}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -22,13 +22,6 @@ pygmentsStyle = "tango"
[permalinks]
blog = "/:section/:year/:month/:day/:slug/"
## Configuration for BlackFriday markdown parser: https://github.com/russross/blackfriday
[blackfriday]
plainIDAnchors = true
hrefTargetBlank = true
angledQuotes = false
latexDashes = true
# Image processing configuration.
[imaging]
resampleFilter = "CatmullRom"
......@@ -51,6 +44,7 @@ languageName ="English"
weight = 1
[markup]
defaultMarkdownHandler = "goldmark"
[markup.goldmark]
[markup.goldmark.renderer]
unsafe = true
......
......@@ -8,7 +8,7 @@ description: >
## Abstract
Your first program shall greet the world with a friendly "Hello World!", what else? For that, we will use a {{< api-link module="kwidgetsaddons" link="KMessageBox" >}} and customise one of the buttons.
Your first program shall greet the world with a friendly "Hello World!", what else? For that, we will use a [KMessageBox](docs:kwidgetsaddons;KMessageBox) and customise one of the buttons.
![](result.png)
......
{{/*
SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu>
SPDX-License-Identifier: LGPL-3.0-or-later
*/}}
{{ if hasPrefix .Destination "docs:" }}
{{ $dest := substr .Destination 5 }}
{{ $module := (index (split $dest ";") 0) }}
{{ $link := (index (split $dest ";") 1) }}
{{ $filename := $link }}
{{ $anchor := "" }}
{{ $url := printf "_data/%s.json" $module }}
{{ $data := getJSON $url }}
{{ $dataMap := getJSON "_data/components_map.json" }}
{{ if in $link "::" }}
{{ $class := (index (split $link "::") 0) }}
{{ $member := (index (split $link "::") 1) }}
{{ range $data.tagfile.compound }}
{{ if (eq (index .name "$") $class) }}
{{ $filename = (index .filename "$") }}
{{ if .member }}
{{ range .member }}
{{ if (eq (index .name "$") $member) }}
{{ $anchor = (printf "#%s" (index .anchor "$")) }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ else }}
{{ range $data.tagfile.compound }}
{{ if (eq (index .name "$") $link) }}
{{ $filename = (index .filename "$") }}
{{ end }}
{{ end }}
{{ end }}
<a href="{{ (index $dataMap $module) }}{{ $filename }}{{ $anchor }}" class="api-link">
{{ .Text | safeHTML }}
</a>
{{ else }}
<a href="{{ .Destination | safeURL }}" {{ with .Title}}title="{{ . }}"{{ end }}>
{{ .Text | safeHTML }}
</a>
{{ end }}
......@@ -11,18 +11,54 @@ from xml.etree.ElementTree import fromstring
import os
import requests
for tag_file in [
'https://api.kde.org/frameworks/kdeclarative/html/KDeclarative.tags',
'https://api.kde.org/frameworks/ki18n/html/KI18n.tags',
'https://api.kde.org/frameworks/kcoreaddons/html/KCoreAddons.tags',
'https://api.kde.org/frameworks/kio/html/KIO.tags',
'https://api.kde.org/frameworks/kxmlgui/html/KXmlGui.tags',
'https://api.kde.org/frameworks/kconfigwidgets/html/KConfigWidgets.tags',
'https://api.kde.org/frameworks/kwidgetsaddons/html/KWidgetsAddons.tags',
]:
r = requests.get(tag_file)
TAG_FILES = [
{
'tags': 'https://api.kde.org/frameworks/kdeclarative/html/KDeclarative.tags',
'base_url': 'https://api.kde.org/frameworks/kdeclarative/html/'
},
{
'tags': 'https://api.kde.org/frameworks/ki18n/html/KI18n.tags',
'base_url': 'https://api.kde.org/frameworks/ki18n/html/'
},
{
'tags': 'https://api.kde.org/frameworks/kcoreaddons/html/KCoreAddons.tags',
'base_url': 'https://api.kde.org/frameworks/kcoreaddons/html/'
},
{
'tags': 'https://api.kde.org/frameworks/kio/html/KIO.tags',
'base_url': 'https://api.kde.org/frameworks/kio/html/'
},
{
'tags': 'https://api.kde.org/frameworks/kxmlgui/html/KXmlGui.tags',
'base_url': 'https://api.kde.org/frameworks/kXmlGui/html/'
},
{
'tags': 'https://api.kde.org/frameworks/kconfigwidgets/html/KConfigWidgets.tags',
'base_url': 'https://api.kde.org/frameworks/kconfigwidgets/html/'
},
{
'tags': 'https://api.kde.org/frameworks/kwidgetsaddons/html/KWidgetsAddons.tags',
'base_url': 'https://api.kde.org/frameworks/kwidgetsaddons/html/'
},
{
'tags': 'https://invent.kde.org/websites/quality-kde-org/-/raw/master/apidox/data/5.15/qtquickcontrols.tags',
'base_url': 'https://doc.qt.io/qt-5/'
}
]
components_map = {}
for tag_file in TAG_FILES:
r = requests.get(tag_file['tags'])
Path("_data").mkdir(parents=True, exist_ok=True)
with open('_data/' + os.path.basename(os.path.splitext(tag_file)[0]).lower() + '.json', 'w') as f:
component_name = os.path.basename(os.path.splitext(tag_file['tags'])[0]).lower()
with open('_data/' + component_name + '.json', 'w') as f:
dump(bf.data(fromstring(r.content)), f)
components_map[component_name] = tag_file['base_url']
with open('_data/components_map.json', 'w') as f:
dump(components_map, f)
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