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

docs: navigation improvements #1056

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ Hatchet replaces difficult to manage legacy queues or pub/sub systems so you can

Hatchet is available as a cloud version or self-hosted. See the following docs to get up and running quickly:

- [Hatchet Cloud Quickstart](https://docs.hatchet.run/home/hatchet-cloud-quickstart)
- [Hatchet Cloud Quickstart](https://docs.hatchet.run/home/quickstart_cloud)
- [Hatchet Self-Hosted](https://docs.hatchet.run/self-hosting)

Hatchet supports your technology stack with open-source SDKs for Python, Typescript, and Go. To get started, see the language-specific guides here:

- [Python SDK Docs](https://docs.hatchet.run/sdks/python-sdk) | [Python SDK Quickstart](https://github.com/hatchet-dev/hatchet-python-quickstart)
- [Typescript SDK Docs](https://docs.hatchet.run/sdks/typescript-sdk) | [Typescript SDK Quickstart](https://github.com/hatchet-dev/hatchet-typescript-quickstart)
- [Go SDK Docs](https://docs.hatchet.run/sdks/go-sdk) | [Go SDK Quickstart](https://github.com/hatchet-dev/hatchet-go-quickstart)
- [Python SDK Docs](https://docs.hatchet.run/) | [Python SDK Quickstart](https://github.com/hatchet-dev/hatchet-python-quickstart)
- [Typescript SDK Docs](https://docs.hatchet.run/) | [Typescript SDK Quickstart](https://github.com/hatchet-dev/hatchet-typescript-quickstart)
- [Go SDK Docs](https://docs.hatchet.run/) | [Go SDK Quickstart](https://github.com/hatchet-dev/hatchet-go-quickstart)

### SDK repositories

Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/components/molecules/nav-bar/nav-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default function MainNav({ user }: MainNavProps) {
<DropdownMenuItem
onClick={() =>
window.open(
'https://docs.hatchet.run/home/basics/steps',
'https://docs.hatchet.run/home/foundations_steps',
'_blank',
)
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/src/pages/main/workers/$worker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export default function ExpandedWorkflowRun() {
<div className="mb-4 text-sm text-gray-700 dark:text-gray-300">
A slot represents one step run on a worker to limit load.{' '}
<a
href="https://docs.hatchet.run/sdks/python-sdk/worker"
href="https://docs.hatchet.run/home/foundations_workers"
className="underline"
>
Learn more.
Expand Down Expand Up @@ -267,7 +267,7 @@ export default function ExpandedWorkflowRun() {
assignment of steps to specific workers.{' '}
<a
className="underline"
href="https://docs.hatchet.run/home/features/worker-assignment/worker-affinity#specifying-worker-labels"
href="https://docs.hatchet.run/home/assignment_worker-affinity"
>
Learn more.
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function WorkersTable() {
</CardHeader>
<CardFooter>
<a
href="https://docs.hatchet.run/home/basics/workers"
href="https://docs.hatchet.run/home/foundations_workers"
className="flex flex-row item-center"
>
<Button onClick={() => {}} variant="link" className="p-0 w-fit">
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/pages/main/workers/webhooks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function Webhooks() {
<a
className="underline"
target="_blank"
href="https://docs.hatchet.run/home/features/webhooks"
href="https://docs.hatchet.run/home/advanced_webhook-workers"
rel="noreferrer"
>
Learn more.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export function StepRunPlayground({
Attempt Cancel
</>
</Button>
<a href="https://docs.hatchet.run/home/features/cancellation">
<a href="https://docs.hatchet.run/home/errors_cancellation-signaling">
<Button
onClick={handleOnCancel}
variant="link"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function WorkflowTable() {
</CardHeader>
<CardFooter>
<a
href="https://docs.hatchet.run/home/basics/workflows"
href="https://docs.hatchet.run/home/foundations_workflows"
className="flex flex-row item-center"
>
<Button onClick={() => {}} variant="link" className="p-0 w-fit">
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/pages/onboarding/get-started/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ export default function GetStarted() {
onClick={() => {
// Explore advanced topics in the docs
window.open(
'https://docs.hatchet.run/home/basics/steps',
'https://docs.hatchet.run/home/foundations_steps',
'_blank',
);
}}
Expand Down
118 changes: 118 additions & 0 deletions frontend/docs/components/FrameworkSelector.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
"use client";

import React from 'react';
import { useLanguage } from '../context/LanguageContext';
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
DialogClose,
} from "@/components/ui/dialog"
import { Button } from '@/components/ui/button';
import { BiChevronDown, BiPlus } from 'react-icons/bi';


interface FrameworkSelectorProps {
className?: string;
}

export const FrameworkSelector: React.FC<FrameworkSelectorProps> = ({ className }) => {
const { selected, setSelectedLanguage, languages } = useLanguage();

return (
<>
<Dialog>
<DialogTrigger asChild>
<Button className="inline-flex items-center gap-2 px-4 py-2 border rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 dark:border-gray-700 dark:bg-background dark:text-foreground">
{selected.worker?.icon} {selected.worker?.name || "Select Language"}
{selected['api-server'] && selected['api-server']?.name !== selected.worker?.name && <> <BiPlus /> {selected['api-server']?.icon} {selected['api-server']?.name}</>}
<BiChevronDown className="ml-2" />
</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-[725px] w-[95vw] max-h-[90vh] overflow-y-auto">
<DialogHeader>
<DialogTitle>Personalize Your Docs</DialogTitle>
<DialogDescription>
Select the programming language and frameworks you want to use for code examples.
</DialogDescription>
</DialogHeader>

<div className="space-y-4">
<div className="space-y-2">
<h4 className="font-medium">Hatchet Worker Language</h4>
<p className="text-sm">
The worker language is the language that your hatchet functions and workflows will be written in.
</p>
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-2">
{languages.worker.map((lang) => (
<button
key={lang.name}
className={`
aspect-square flex flex-col items-center justify-center gap-1.5
border rounded-md hover:bg-gray-50 transition-colors p-1
${selected.worker?.name === lang.name
? 'border-blue-500 bg-blue-50 ring-1 ring-blue-500 ring-opacity-50 text-blue-900'
: ''}
`}
onClick={() => setSelectedLanguage("worker", lang)}
>
<div className="text-3xl">{lang.icon}</div>
<div className="text-xs font-medium leading-none text-center whitespace-pre-line">
{lang.name.replace('(', '\n(')}
</div>
</button>
))}
</div>
</div>

<div className="space-y-2">
<h4 className="font-medium">API Server</h4>
<p className="text-sm">
The API server framework is where you schedule work for your hatchet functions.
</p>
<div className="max-h-[230px] overflow-y-auto pr-2">
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-2">
{languages['api-server'].map((lang) => (
<button
key={lang.name}
className={`
aspect-square flex flex-col items-center justify-center gap-2.5
border rounded-md hover:bg-gray-50 transition-colors p-1
${selected['api-server']?.name === lang.name
? 'border-blue-500 bg-blue-50 ring-1 ring-blue-500 ring-opacity-50 text-blue-900'
: ''}
`}
onClick={() => setSelectedLanguage("api-server", lang)}
>
<div className="text-3xl">{lang.icon}</div>
<div className="text-xs font-medium leading-none text-center whitespace-pre-line">
{lang.name.replace('(', '\n(')}
</div>
</button>
))}
</div>
</div>
</div>
</div>

<div className="flex flex-col sm:flex-row justify-between mt-6 pt-4 border-t gap-4">
<p className="text-sm">
Don't see your favorite framework?
<a href="https://github.com/hatchet-dev/hatchet/issues/new?template=feature_request.md&labels=feature-request&title=Framework+Request:" target="_blank">
<Button variant="link" size="sm">Request a Framework</Button>
</a>
</p>
<DialogClose asChild>
<Button variant="outline">Save Changes</Button>
</DialogClose>
</div>
</DialogContent>
</Dialog>
</>
);
};

export default FrameworkSelector;
18 changes: 11 additions & 7 deletions frontend/docs/components/UniversalTabs.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import React from 'react';
import { Tabs } from 'nextra/components';
import { useLanguage } from '../context/LanguageContext';
import { PersistenceKeys, useLanguage } from '../context/LanguageContext';

interface UniversalTabsProps {
items: string[];
children: React.ReactNode;
key?: PersistenceKeys;
}

export const UniversalTabs: React.FC<UniversalTabsProps> = ({ items, children }) => {
const { selectedLanguage, setSelectedLanguage } = useLanguage();
export const UniversalTabs: React.FC<UniversalTabsProps> = ({ children, key = "worker" }) => {
const { selected, setSelectedLanguage, languages } = useLanguage();

const selectedIndex = selected[key]
? languages[key].findIndex(lang => lang.name === selected[key]?.name)
: 0;

return (
<Tabs
items={items}
selectedIndex={items.includes(selectedLanguage) ? items.indexOf(selectedLanguage) : 0}
onChange={(index) => setSelectedLanguage(items[index])}
items={languages[key].map(lang => lang.name)}
selectedIndex={selectedIndex}
onChange={(index) => setSelectedLanguage(key, languages[key][index])}
>
{children}
</Tabs>
Expand Down
8 changes: 4 additions & 4 deletions frontend/docs/components/code/CodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ export const CodeBlock = ({ source, target }: CodeRendererProps) => {
const [plainText, setPlainText] = React.useState(false);
const [copied, setCopied] = React.useState(false);

const parsed = parseDocComments(source.raw, target, collapsed);
const { text: parsed, expandable } = parseDocComments(source.raw, target, collapsed);

return <>
<div className="sticky top-0 z-10 bg-background flex flex-row gap-4 justify-between items-center pl-2 mb-2">
<div className="sticky top-0 z-10 flex flex-row gap-4 justify-between items-center pl-2 mb-2">
<a href={source.githubUrl} target="_blank" rel="noopener noreferrer" className="text-xs text-gray-500 font-mono hover:underline">{source.props.path}</a>
<div className="flex gap-2 justify-end">
<Button variant="ghost" size="sm" onClick={() => setCollapsed(!collapsed)}>
{expandable &&<Button variant="ghost" size="sm" onClick={() => setCollapsed(!collapsed)}>
{collapsed ? <><UnfoldVertical className="w-4 h-4 mr-2" />Expand</> : <><FoldVertical className="w-4 h-4 mr-2" />Collapse</>}
</Button>
</Button>}
<Button variant="outline" size="sm" onClick={() => {
navigator.clipboard.writeText(parsed);
setCopied(true);
Expand Down
53 changes: 0 additions & 53 deletions frontend/docs/components/code/CodeTabs.tsx

This file was deleted.

10 changes: 6 additions & 4 deletions frontend/docs/components/code/codeParser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ export const parseDocComments = (
source: string,
target: string,
collapsed: boolean = false,
): string => {
): { text: string, expandable: boolean } => {
const lines = source.split('\n');
let isSnippet = false;
let isCollecting = false;
const resultLines: string[] = [];
let expandable = false;

for (let i = 0; i < lines.length; i++) {
const line = lines[i];
Expand All @@ -50,6 +51,7 @@ export const parseDocComments = (

// Collect until '...'
if (isCollecting && startsWithPrefixAndChar(line, '...')) {
expandable = true;
if (collapsed) {
isCollecting = false;
resultLines.push(line);
Expand All @@ -59,7 +61,7 @@ export const parseDocComments = (
}

// Stop at ‼️
if (isSnippet && line.includes('‼️')) {
if (isSnippet && (line.includes('‼️') || line.includes('!!'))) {
break;
}
}
Expand All @@ -75,8 +77,8 @@ export const parseDocComments = (
}

if (resultLines.length === 0) {
return `🚨 No snippet found for ${target} \n\n${source}`;
return { text: `🚨 No snippet found for ${target} \n\n${source}`, expandable: false };
}

return resultLines.join('\n');
return { text: resultLines.join('\n'), expandable };
};
Loading
Loading