Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge pull request #3943 from mathesar-foundation/manual_docs_publishing #3944

Closed
wants to merge 11 commits into from
18 changes: 0 additions & 18 deletions .github/workflows/deploy-docs.yml

This file was deleted.

1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
site
14 changes: 14 additions & 0 deletions docs/docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,17 @@
border-bottom: 2px solid var(--md-primary-fg-color--light);
color: var(--md-primary-bg-color--lightest);
}

/* Make header title smaller */
.md-header__title { font-size: 0.8rem; }
[dir="ltr"] .md-header__title { margin-left: 0; }

/* Make header theme switcher smaller */
.md-header__option .md-header__button { padding: 0.2rem; }
.md-header__option .md-header__button { padding: 0.2rem; }
.md-header__option .md-header__button svg { height: 1rem; width: 1rem; }

/* Make version switcher smaller */
.md-version { font-size: 0.7rem; font-weight: normal; }
[dir="ltr"] .md-version__current { margin-left: 0.6rem; }
.md-version__list { margin: 1.7rem 0 0 0; }
4 changes: 4 additions & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ theme:
toggle:
icon: material/brightness-4
name: Switch to light mode
custom_dir: overrides

extra_css:
- stylesheets/extra.css
Expand Down Expand Up @@ -118,3 +119,6 @@ markdown_extensions:

extra:
mathesar_version: 0.1.7
version:
provider: mike
alias: true
91 changes: 91 additions & 0 deletions docs/overrides/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{% extends "base.html" %}

{% block content %}
<h1>Loading...</h1>

<div class="help-404" style="display:none;">
<p>
If you followed a link here, we'd appreciate it if you would open a
<a href="https://github.com/mathesar-foundation/mathesar/issues">
GitHub issue
</a>
describing how you got here so we can fix the link.
</p>
<p>
You can also ask the Mathesar team for help by reaching out on
<a href="https://wiki.mathesar.org/community/matrix/">Matrix</a>.
</p>
</div>
{% endblock %}

{% block scripts %}
{{ super() }}
<script>
// @ts-check

const defaultVersionAlias = 'latest';

/**
* Add strings here if your docs URL has any prefixes before the version
* such as a repo name, a subdirectory, or a language code.
*
* If your docs URLs look like `https://example.com/docs/en/1.0/foo/bar`
* then set this value to `['docs', 'en']`.
*/
const pathPartsBeforeVersion = [];
const versionPositionInPath = pathPartsBeforeVersion.length;

/** @returns {Promise<string | undefined>} */
async function getRedirectionTarget() {
try {
const response = await fetch('/versions.json');
if (!response.ok) return undefined;

/** @type {({ version: string; title: string; aliases: string[]; })[]} */
const versionBlobs = await response.json();
const versionLikeStrings = versionBlobs.flatMap(v => [v.version, ...v.aliases]);

const url = new URL(window.location.href);
const pathParts = url.pathname.split('/').filter(Boolean);
const firstPathPart = pathParts[versionPositionInPath];

if (versionLikeStrings.includes(firstPathPart)) return undefined;

return [
'',
...pathPartsBeforeVersion,
defaultVersionAlias,
...pathParts,
url.search + url.hash
].join('/');
}
catch (e) {
return undefined;
}
}

function setupErrorPageContent() {
const h1 = document.querySelector('h1');
if (h1) {
h1.textContent = 'Page Not Found';
}

/** @type {HTMLElement | null} */
const help404 = document.querySelector('.help-404');
if (help404) {
help404.style.display = 'block';
}
}

async function init() {
const redirectionTarget = await getRedirectionTarget();
if (redirectionTarget) {
window.location.href = redirectionTarget;
} else {
setupErrorPageContent();
}
}

init();
</script>
{% endblock %}
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ mkdocs-material==8.5.11
mkdocs-redirects==1.2.0
mkdocs-macros-plugin==0.7.0
mkdocs-placeholder-plugin==0.3.1
mkdocstrings==0.24.2
mkdocstrings-python==1.9.2
mkdocstrings==0.25.2
mkdocstrings-python==1.10.8
Loading