From 41e49b184c6d87bad24af2d1ca1dac23ddb493cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ad=C3=A1mek?= Date: Tue, 14 Jan 2025 11:42:54 +0100 Subject: [PATCH 1/3] feat: switch new OpenAPI docs to `/api/v2` --- apify-api/scripts/script-requirements.txt | 45 ----------------------- apify-docs-theme/static/js/custom.js | 4 +- docusaurus.config.js | 4 +- static/robots.txt | 3 +- 4 files changed, 6 insertions(+), 50 deletions(-) delete mode 100644 apify-api/scripts/script-requirements.txt diff --git a/apify-api/scripts/script-requirements.txt b/apify-api/scripts/script-requirements.txt deleted file mode 100644 index a57822f83f..0000000000 --- a/apify-api/scripts/script-requirements.txt +++ /dev/null @@ -1,45 +0,0 @@ -anyio==4.8.0 -attrs==23.2.0 -backoff==2.2.1 -certifi==2024.12.14 -charset-normalizer==3.4.1 -click==8.1.8 -colorama==0.4.6 -graphql-core==3.2.5 -h11==0.14.0 -httpcore==1.0.7 -httpx==0.27.0 -hypothesis==6.123.17 -hypothesis-graphql==0.11.0 -hypothesis-jsonschema==0.23.1 -idna==3.10 -iniconfig==2.0.0 -jsonschema==4.23.0 -jsonschema-specifications==2023.12.1 -junit-xml==1.9 -MarkupSafe==2.1.5 -multidict==6.1.0 -packaging==24.2 -pluggy==1.5.0 -pyrate-limiter==3.7.0 -pytest==8.3.4 -pytest-subtests==0.7.0 -python-slugify==8.0.4 -PyYAML==6.0.2 -referencing==0.35.1 -requests==2.32.3 -rpds-py==0.18.1 -ruamel.yaml==0.18.6 -ruamel.yaml.clib==0.2.8 -schemathesis==3.39.6 -six==1.17.0 -sniffio==1.3.1 -sortedcontainers==2.4.0 -starlette==0.37.2 -starlette-testclient==0.4.1 -text-unidecode==1.3 -tomli==2.2.1 -tomli_w==1.1.0 -urllib3==2.3.0 -Werkzeug==3.1.3 -yarl==1.18.3 diff --git a/apify-docs-theme/static/js/custom.js b/apify-docs-theme/static/js/custom.js index 7632c29c65..10723945ff 100644 --- a/apify-docs-theme/static/js/custom.js +++ b/apify-docs-theme/static/js/custom.js @@ -78,8 +78,7 @@ function scrollOpenApiSidebarItemIntoView() { function redirectOpenApiDocs() { const { hash, pathname, origin } = new URL(window.location.href); - // TODO change to '/api/v2' - if (pathname.replace(/\/$/, '') !== '/api/v2-new') { + if (pathname.startsWith('/api/v2') && pathname.startsWith('/api/v2-')) { return; } @@ -129,5 +128,6 @@ window.addEventListener('load', () => { }); window.addEventListener('popstate', () => { + setTimeout(() => redirectOpenApiDocs(), 50); setTimeout(() => scrollOpenApiSidebarItemIntoView(), 50); }); diff --git a/docusaurus.config.js b/docusaurus.config.js index 1ad9457188..64d6d77eba 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -132,7 +132,7 @@ module.exports = { specs: [ { spec: './apify-api/openapi/openapi.yaml', - route: '/api/v2/', + route: '/api/v2-redoc/', }, ], theme: { @@ -177,7 +177,7 @@ module.exports = { { id: 'openapi', path: './sources/api', - routeBasePath: 'api/v2-new', // TODO change to `api/v2` once we are ready + routeBasePath: 'api/v2', rehypePlugins: [externalLinkProcessor], showLastUpdateAuthor: false, showLastUpdateTime: false, diff --git a/static/robots.txt b/static/robots.txt index cb80f15c39..0994c655af 100644 --- a/static/robots.txt +++ b/static/robots.txt @@ -1,4 +1,5 @@ User-agent: * Sitemap: https://docs.apify.com/sitemap.xml Disallow: https://docs.apify.com/api/v2-old -Disallow: https://docs.apify.com/api/v2-new +Disallow: https://docs.apify.com/api/v2-redoc +Disallow: https://docs.apify.com/api/v2 From 3c0b48dba9ffd1cd4644a0a11679ab4cb2743b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ad=C3=A1mek?= Date: Tue, 14 Jan 2025 12:10:52 +0100 Subject: [PATCH 2/3] address feedback --- apify-docs-theme/static/js/custom.js | 2 +- src/theme/DocSidebarItem/Category/index.js | 2 +- static/robots.txt | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/apify-docs-theme/static/js/custom.js b/apify-docs-theme/static/js/custom.js index 10723945ff..8cc567067a 100644 --- a/apify-docs-theme/static/js/custom.js +++ b/apify-docs-theme/static/js/custom.js @@ -78,7 +78,7 @@ function scrollOpenApiSidebarItemIntoView() { function redirectOpenApiDocs() { const { hash, pathname, origin } = new URL(window.location.href); - if (pathname.startsWith('/api/v2') && pathname.startsWith('/api/v2-')) { + if (!pathname.startsWith('/api/v2') || pathname.startsWith('/api/v2-')) { return; } diff --git a/src/theme/DocSidebarItem/Category/index.js b/src/theme/DocSidebarItem/Category/index.js index 025ab30beb..ff3d37ddc5 100644 --- a/src/theme/DocSidebarItem/Category/index.js +++ b/src/theme/DocSidebarItem/Category/index.js @@ -137,7 +137,7 @@ export default function DocSidebarItemCategory({ item, onItemClick, activePath, } } - console.log(item); + // console.log('sidebar category', item); return (
  • Date: Tue, 14 Jan 2025 12:21:33 +0100 Subject: [PATCH 3/3] add badges to category pages --- apify-docs-theme/src/theme/custom.css | 16 ++++++++++++++++ src/theme/DocCard/index.js | 18 +++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/apify-docs-theme/src/theme/custom.css b/apify-docs-theme/src/theme/custom.css index 2a51fd0513..48ceaf652c 100644 --- a/apify-docs-theme/src/theme/custom.css +++ b/apify-docs-theme/src/theme/custom.css @@ -1698,6 +1698,7 @@ iframe[src*="youtube"] { justify-content: start; } +.openapi-endpoint.api-method::before, .api-method > .menu__link::before, .schema > .menu__link::before { width: 55px; @@ -1726,73 +1727,88 @@ iframe[src*="youtube"] { } .get > .menu__link::before, +.openapi-endpoint.api-method.get::before, .theme-api-markdown .openapi__method-endpoint .badge--primary { background-color: var(--ifm-color-info-contrast-background); color: var(--ifm-color-info-contrast-foreground); border-color: var(--ifm-color-info-dark); } +.openapi-endpoint.api-method.get::before, .get > .menu__link::before { content: 'get'; } +.openapi-endpoint.api-method.post::before, .post > .menu__link::before { content: 'post'; } .post > .menu__link::before, +.openapi-endpoint.api-method.post::before, .theme-api-markdown .openapi__method-endpoint .badge--success { background-color: var(--ifm-color-success-contrast-background); color: var(--ifm-color-success-contrast-foreground); border-color: var(--ifm-color-success-dark); } +.openapi-endpoint.api-method.delete::before, .delete > .menu__link::before { content: 'del'; } .delete > .menu__link::before, +.openapi-endpoint.api-method.delete::before, .theme-api-markdown .openapi__method-endpoint .badge--danger { background-color: var(--ifm-color-danger-contrast-background); color: var(--ifm-color-danger-contrast-foreground); border-color: var(--ifm-color-danger-dark); } +.openapi-endpoint.api-method.put::before, .put > .menu__link::before { content: 'put'; } .put > .menu__link::before, +.openapi-endpoint.api-method.put::before, .theme-api-markdown .openapi__method-endpoint .badge--info { background-color: var(--ifm-color-warning-contrast-background); color: var(--ifm-color-warning-contrast-foreground); border-color: var(--ifm-color-warning-dark); } +.openapi-endpoint.api-method.patch::before, .patch > .menu__link::before { content: 'patch'; } .patch > .menu__link::before, +.openapi-endpoint.api-method.patch::before, .theme-api-markdown .openapi__method-endpoint .badge--warning { background-color: var(--ifm-color-success-contrast-background); color: var(--ifm-color-success-contrast-foreground); border-color: var(--ifm-color-success-dark); } +.openapi-endpoint.api-method.head::before, .head > .menu__link::before { content: 'head'; } .head > .menu__link::before, +.openapi-endpoint.api-method.head::before, .event > .menu__link::before, +.openapi-endpoint.api-method.event::before, .schema > .menu__link::before, +.openapi-endpoint.api-method.schema::before, .theme-api-markdown .openapi__method-endpoint .badge--secondary { background-color: var(--ifm-color-secondary-contrast-background); color: var(--ifm-color-secondary-contrast-foreground); border-color: var(--ifm-color-secondary-dark); } +.openapi-endpoint.api-method.event::before, .event > .menu__link::before { content: 'event'; } diff --git a/src/theme/DocCard/index.js b/src/theme/DocCard/index.js index d95461daf7..d09e428128 100644 --- a/src/theme/DocCard/index.js +++ b/src/theme/DocCard/index.js @@ -35,7 +35,7 @@ function CardContainer({ href, children }) { ); } -function CardLayout({ href, icon, title, description }) { +function CardLayout({ href, icon, title, description, className }) { if (href.startsWith('/api')) { description = ''; } @@ -45,7 +45,7 @@ function CardLayout({ href, icon, title, description }) { href={href}> {icon} {title} @@ -78,8 +78,20 @@ function CardCategory({ item }) { } function CardLink({ item }) { - const icon = isInternalUrl(item.href) ? '📄️' : '🔗'; const doc = useDocById(item.docId ?? undefined); + + if (item.href.startsWith('/api/v2')) { + return ( + + ); + } + + const icon = isInternalUrl(item.href) ? '📄️' : '🔗'; return (