Skip to content

Commit

Permalink
Merge branch 'source' into add_docs_pages
Browse files Browse the repository at this point in the history
  • Loading branch information
PiffPaffM committed Sep 8, 2021
2 parents 5a78cee + 0be4d28 commit 8a1f42f
Show file tree
Hide file tree
Showing 21 changed files with 1,492 additions and 222 deletions.
8 changes: 4 additions & 4 deletions components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function Header({ docsType = "haystack" }: Props) {
return (
<header className="sticky top-0 p-2 sm:px-6 sm:py-3 z-10 w-full xl:max-w-8xl mx-auto flex items-center justify-between bg-dark-blue border-b border-medium-grey dark:bg-black">
<Link href="/" passHref>
<div className="w-44 lg:w-60">
<div className="w-44 lg:w-60 cursor-pointer">
<svg
xmlns="http:https://www.w3.org/2000/svg"
viewBox="0 0 184 47"
Expand Down Expand Up @@ -100,17 +100,17 @@ export default function Header({ docsType = "haystack" }: Props) {
</div>
<div className="mr-8 xl:mr-12 2xl:mr-16">
<Link href="/community/join">
<div className="text-white font-bold lg:text-xl xl:text-2xl cursor-pointer">
<div className="font-bold lg:text-xl xl:text-2xl cursor-pointer text-green-dark-theme">
Join Slack
</div>
</Link>
</div>
<div className="mr-8 xl:mr-12 2xl:mr-16 flex">
<div className="mr-8 xl:mr-12 2xl:mr-16">
<Link href="https://www.meetup.com/de-DE/open-nlp-meetup/">
<a
target="_blank"
href="https://www.meetup.com/de-DE/open-nlp-meetup/"
className="text-white font-bold lg:text-xl xl:text-2xl cursor-pointer"
className="text-white font-bold lg:text-xl xl:text-2xl cursor-pointer text-green-dark-theme"
rel="noopener noreferrer"
>
Join Open NLP
Expand Down
32 changes: 32 additions & 0 deletions docs/latest/overview/get_started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,38 @@
</p>
</div>
),
},
{
title: "Docker",
content: (
<div>
<p>
Run a demo via Docker.
</p>
<pre>
<code>git clone https://github.com/deepset-ai/haystack.git</code>
<code>cd haystack</code>
<code>docker-compose pull</code>
<code>docker-compose up</code>
</pre>
</div>
),
},
{
title: "Docker (GPU)",
content: (
<div>
<p>
Run a demo via Docker using GPUs.
</p>
<pre>
<code>git clone https://github.com/deepset-ai/haystack.git</code>
<code>cd haystack</code>
<code>docker-compose -f docker-compose-gpu.yml pull</code>
<code>docker-compose -f docker-compose-gpu.yml up</code>
</pre>
</div>
),
},
]}
/>
Expand Down
1 change: 1 addition & 0 deletions docs/v0.6.0/overview/get_started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
Note: On Windows add the arg `-f https://download.pytorch.org/whl/torch_stable.html` to install PyTorch correctly

<div style={{ marginBottom: "3rem" }} />

<!-- _comment: !! Have a tab for docker!! -->
<!-- -comment: !! Have a hello world example!! -->

Expand Down
1 change: 1 addition & 0 deletions docs/v0.7.0/overview/get_started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
Note: On Windows add the arg `-f https://download.pytorch.org/whl/torch_stable.html` to install PyTorch correctly

<div style={{ marginBottom: "3rem" }} />

<!-- _comment: !! Have a tab for docker!! -->
<!-- -comment: !! Have a hello world example!! -->

Expand Down
8 changes: 0 additions & 8 deletions docs/v0.9.0/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,6 @@
{
"slug": "lfqa",
"title": "Generative QA with \"LFQA\""
},
{
"slug": "question-generation",
"title": "Question Generation"
},
{
"slug": "query-classifier",
"title": "Query Classifier"
}
]
},
Expand Down
7 changes: 4 additions & 3 deletions docs/v0.9.0/overview/roadmap.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ We hope this helps to clarify the direction of the open-source project and inspi
<div style={{ marginBottom: "3rem" }} />

## How to access it
We decided for Zenhub, as it allows a close integration with GitHub and real-time sharing of roadmaps and sprints.

### Add Zenhub Plugin
Visit our Zenhub Roadmap [here](https://app.zenhub.com/workspaces/open-source-5f4fd244079454000f05f047/roadmap). You will need to be logged in with your GitHub account and Zenhub will ask for permission to integrate with your GitHub account.

We decided for Zenhub, as it allows a close integration with GitHub and real-time sharing of roadmaps and sprints.
Once you have installed the browser plugin below, you will see additional tabs and infos on the Haystack GitHub page.
### Alternative: Add Zenhub Plugin
Once you have installed the browser plugin below, you will see additional tabs and infos directly on the Haystack GitHub page.

Zenhub Plugin: https://www.zenhub.com/extension

Expand Down
10 changes: 9 additions & 1 deletion lib/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const getDownloadUrl = async ({
const res = await octokit.rest.repos.getContent({
owner: "deepset-ai",
repo: "haystack",
path: `docs${version ? `/${version}` : ""}${repoPath}${filename}`,
path: `docs${version && version !== "latest" ? `/${version}` : ""}${repoPath}${filename}`,
});
if (Array.isArray(res.data)) return;
if (!res.data.download_url) return;
Expand All @@ -34,3 +34,11 @@ export const getStargazersCount = async () => {
});
return res.data.stargazers_count;
};

export const getHaystackReleaseTagNames = async () => {
const res = await octokit.rest.repos.listReleases({
owner: "deepset-ai",
repo: "haystack",
});
return res.data.map((release) => release.tag_name);
};
77 changes: 33 additions & 44 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,26 @@ import { join } from "path";
import remark from "remark";
import html from "remark-html";
import slug from "remark-slug";
import remarkPrism from "remark-prism";
import autolink from "remark-autolink-headings";
import prism from "remark-prism";
import GitHubSlugger from "github-slugger";
import imgLinks from "@pondorasti/remark-img-links";
import semverCompare from "semver-compare";
import { getStargazersCount } from "./github";
import { getHaystackReleaseTagNames, getStargazersCount } from "./github";
import { MDXRemoteSerializeResult } from "next-mdx-remote";

// we have to explicitly require prismjs and loadLanguages so that they're available during revalidation on Vercel
const Prism = require("prismjs");
const loadLanguages = require("prismjs/components/index");

export const markdownToHtml = async ({
content,
downloadUrl,
}: {
content: string;
downloadUrl: string;
}) => {
loadLanguages();

const result = await remark()
.use(imgLinks, {
absolutePath: downloadUrl,
Expand All @@ -28,7 +33,7 @@ export const markdownToHtml = async ({
.use(slug)
// @ts-ignore
.use(autolink)
.use(prism)
.use(remarkPrism)
.process(content);

return {
Expand Down Expand Up @@ -68,11 +73,11 @@ export const getStaticLayoutProps = async ({
});
};

const menu = getMenu(version);
const menu = await getMenu(version);

const toc = getHeadings();

const latestVersion = getLatestVersion();
const latestVersion = await getLatestVersion();
const editOnGitHubLink = `https://github.com/deepset-ai/haystack-website/blob/source/docs/${
version || latestVersion
}/${type}/${docTitleSlug.split("-").join("_")}.mdx`;
Expand All @@ -82,69 +87,53 @@ export const getStaticLayoutProps = async ({
return { menu, toc, editOnGitHubLink, stars };
};

export const getMenu = (version?: string) => {
const latestVersion = getLatestVersion();
const menuPath = join(
process.cwd(),
`docs/${version || latestVersion}/menu.json`
);
return JSON.parse(fs.readFileSync(menuPath, "utf8"));
export const getMenu = async (version?: string) => {
const latestVersion = await getLatestVersion();
const menu = await import(`../docs/${version || latestVersion}/menu.json`);
// JSON files don’t have a default export, so we have to explicitly return the default property
return menu.default;
};

export const getBenchmarks = (type: string, name: string, version?: string) => {
const latestVersion = getLatestVersion();
const benchmarksPath = join(
process.cwd(),
`benchmarks/${version || latestVersion}/${type}/${name}.json`
);
return JSON.parse(fs.readFileSync(benchmarksPath, "utf8"));
};

export function getDocsVersions() {
return fs.readdirSync(join(process.cwd(), "docs"));
export async function getDocsVersions() {
const tagNames = await getHaystackReleaseTagNames();
return tagNames.filter((tagName) => tagName.startsWith("v"));
}

export function getVersionFromParams(params: string[]) {
const versions = getDocsVersions();
return versions.find((version) => params.includes(version));
export async function getVersionFromParams(params: string[]) {
const versions = await getDocsVersions();
const latestVersion = "latest";
return versions.find((version) => params.includes(version)) ?? latestVersion;
}

export function getLatestVersion() {
export async function getLatestVersion() {
return "latest";
}

export function getDirectory(category: "overview" | "usage", version?: string) {
const latestVersion = getLatestVersion();
export async function getDirectory(
category: "overview" | "usage",
version?: string
) {
const latestVersion = await getLatestVersion();
return join(process.cwd(), `docs/${version || latestVersion}/${category}`);
}

export function getDirectoryBenchmarks(
export async function getDirectoryBenchmarks(
category: "map" | "performance" | "speed",
version?: string
) {
const latestVersion = getLatestVersion();
const latestVersion = await getLatestVersion();
return join(
process.cwd(),
`benchmarks/${version || latestVersion}/${category}`
);
}

export function getSlugsFromLocalMarkdownFiles(
export async function getSlugsFromLocalMarkdownFiles(
category: "overview" | "usage",
version?: string
) {
const directory = getDirectory(category, version);
const directory = await getDirectory(category, version);
if (!fs.existsSync(directory)) return [];
const filenames = fs.readdirSync(directory);
return filenames.map((file) => file.replace(/\.mdx$/, "").split("_").join("-"));
}

export function getSlugsFromLocalBenchmarksFiles(
category: "map" | "performance" | "speed",
version?: string
) {
const directory = getDirectoryBenchmarks(category, version);
if (!fs.existsSync(directory)) return [];
const filenames = fs.readdirSync(directory);
return filenames;
}
4 changes: 4 additions & 0 deletions next-sitemap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
siteUrl: process.env.SITE_URL || 'https://haystack.deepset.ai',
generateRobotsTxt: true,
}
Loading

0 comments on commit 8a1f42f

Please sign in to comment.