Skip to content

Commit

Permalink
Merge branch 'master' into deployment-continuous-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
TC-MO authored Sep 5, 2024
2 parents e075077 + 10c0390 commit 45ce16a
Show file tree
Hide file tree
Showing 75 changed files with 23,826 additions and 11,605 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
- run: gh workflow run deploy.yaml --repo apify/apify-docs-private
env:
GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
SMARTLOOK_PROJECT_KEY: ${{ secrets.SMARTLOOK_PROJECT_KEY }}
INTERCOM_APP_ID: ${{ secrets.INTERCOM_APP_ID }}
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
env:
APIFY_SIGNING_TOKEN: ${{ secrets.APIFY_SIGNING_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
SMARTLOOK_PROJECT_KEY: ${{ secrets.SMARTLOOK_PROJECT_KEY }}
INTERCOM_APP_ID: ${{ secrets.INTERCOM_APP_ID }}

- name: Set up GitHub Pages
uses: actions/configure-pages@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lychee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
env:
APIFY_SIGNING_TOKEN: ${{ secrets.APIFY_SIGNING_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
SMARTLOOK_PROJECT_KEY: ${{ secrets.SMARTLOOK_PROJECT_KEY }}
INTERCOM_APP_ID: ${{ secrets.INTERCOM_APP_ID }}

- name: Run Lychee Link Checker
id: lychee
Expand Down
18 changes: 7 additions & 11 deletions .github/workflows/publish-theme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
workflow_dispatch:

jobs:
look_for_change:
Expand All @@ -23,15 +24,15 @@ jobs:

- name: Check changes in theme
id: changed-theme-files
uses: tj-actions/changed-files@v44
uses: tj-actions/changed-files@v45
with:
since_last_remote_commit: "true"
files: |
apify-docs-theme/**
publish:
needs: look_for_change
if: needs.look_for_change.outputs.theme_changed == 'true'
if: ${{ needs.look_for_change.outputs.theme_changed == 'true' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -45,32 +46,27 @@ jobs:
cache: 'npm'
cache-dependency-path: 'package-lock.json'
always-auth: 'true'
registry-url: 'https://npm.pkg.github.com/'
scope: '@apify-packages'
env:
NODE_AUTH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_NPM_TOKEN }}

- name: Setup git user and npm
run: |
git config --global user.name "Apify Release Bot"
git config --global user.email "noreply@apify.com"
echo "access=public" > .npmrc
echo "//registry.npmjs.org/:_authToken=${{ secrets.APIFY_SERVICE_ACCOUNT_NPM_TOKEN }}" >> .npmrc
echo "access=public" > ~/.npmrc
echo "@apify-packages:registry=https://npm.pkg.github.com/" >> ~/.npmrc
echo "//registry.npmjs.org/:_authToken=${{ secrets.APIFY_SERVICE_ACCOUNT_NPM_TOKEN }}" >> ~/.npmrc
echo "//npm.pkg.github.com/:_authToken=${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}" >> ~/.npmrc
- name: Bump the theme version
run: |
cd $GITHUB_WORKSPACE/apify-docs-theme
npm version patch --legacy-peer-deps
env:
NODE_AUTH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_NPM_TOKEN }}
- name: Deploy theme to npm
run: |
cd $GITHUB_WORKSPACE/apify-docs-theme
npx -y publish-if-not-exists
env:
NPM_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_NPM_TOKEN }}
GIT_USER: "barjin:${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}"
GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- run: npm run build
env:
SMARTLOOK_PROJECT_KEY: ${{ secrets.SMARTLOOK_PROJECT_KEY }}
INTERCOM_APP_ID: ${{ secrets.INTERCOM_APP_ID }}

lint_content:
name: Lint markdown content
Expand All @@ -41,7 +41,7 @@ jobs:

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44.5.7
uses: tj-actions/changed-files@v45
with:
files: |
**/*.md
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/vale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44.5.7
uses: tj-actions/changed-files@v45
with:
files: |
**/*.{md,mdx}
Expand Down
3 changes: 2 additions & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"link-fragments": false,
"no-duplicate-heading": {
"siblings_only": true
}
},
"no-bare-urls": false
}
7 changes: 3 additions & 4 deletions apify-docs-theme/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apify/docs-theme",
"version": "1.0.128",
"version": "1.0.132",
"description": "",
"main": "./src/index.js",
"files": [
Expand All @@ -19,13 +19,12 @@
"access": "public"
},
"dependencies": {
"@apify/docs-search-modal": "^1.0.26",
"@docusaurus/theme-common": "^2.4.1",
"@apify/docs-search-modal": "^1.1.0",
"@docusaurus/theme-common": "^3.5.2",
"@stackql/docusaurus-plugin-hubspot": "^1.1.0",
"axios": "^1.7.4",
"babel-loader": "^9.1.3",
"docusaurus-gtm-plugin": "^0.0.2",
"docusaurus-plugin-smartlook": "^1.0.2",
"postcss-preset-env": "^9.3.0",
"prism-react-renderer": "^2.0.6"
},
Expand Down
2 changes: 0 additions & 2 deletions apify-docs-theme/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const themeConfig = ({
hideable: true,
},
},
smartlook: { projectKey: process.env.SMARTLOOK_PROJECT_KEY || '-' },
navbar: {
title: 'Apify Docs',
logo: {
Expand Down Expand Up @@ -266,7 +265,6 @@ const themeConfig = ({
});

const plugins = [
'docusaurus-plugin-smartlook',
[
'docusaurus-gtm-plugin',
{
Expand Down
21 changes: 15 additions & 6 deletions apify-docs-theme/src/markdown.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
function updateChangelog(changelog) {
changelog = addHeader(changelog);
changelog = addFrontmatter(changelog);
changelog = pushHeadings(changelog);
changelog = linkUsers(changelog);
changelog = linkPRs(changelog);
changelog = fixUserLinks(changelog);
changelog = fixPRLinks(changelog);
changelog = escapeMDXCharacters(changelog);
return changelog;
}

function addHeader(changelog, header = 'Changelog') {
function addFrontmatter(changelog, header = 'Changelog') {
return `---
title: ${header}
sidebar_label: ${header}
Expand All @@ -19,14 +20,22 @@ function pushHeadings(changelog) {
return changelog.replaceAll(/\n#[^#]/g, '\n## ');
}

function linkUsers(changelog) {
function fixUserLinks(changelog) {
return changelog.replaceAll(/by @([a-zA-Z0-9-]+)/g, 'by [@$1](https://github.com/$1)');
}

function linkPRs(changelog) {
function fixPRLinks(changelog) {
return changelog.replaceAll(/(((https?:\/\/)?(www.)?)?github.com\/[^\s]*?\/pull\/([0-9]+))/g, '[#$5]($1)');
}

function escapeMDXCharacters(changelog) {
return changelog.replaceAll(/<|>/g, (match) => {
return match === '<' ? '&lt;' : '&gt;';
}).replaceAll(/\{|\}/g, (match) => {
return match === '{' ? '&#123;' : '&#125;';
});
}

module.exports = {
updateChangelog,
};
14 changes: 7 additions & 7 deletions apify-docs-theme/src/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function findPathInParentOrThrow(endPath) {
return filePath;
}

async function copyChangelogFromReleases(paths, repo) {
async function generateChangelogFromGitHubReleases(paths, repo) {
const response = await axios.get(`https://api.github.com/repos/${repo}/releases`);
const releases = response.data;

Expand Down Expand Up @@ -81,6 +81,12 @@ function theme(
),
];

if (options.changelogFromRoot) {
copyChangelogFromRoot(pathsToCopyChangelog);
} else {
await generateChangelogFromGitHubReleases(pathsToCopyChangelog, `${context.siteConfig.organizationName}/${context.siteConfig.projectName}`);
}

for (const p of pathsToCopyChangelog) {
// the changelog page has to exist for the sidebar to work - async loadContent() is (apparently) not awaited for by sidebar
if (fs.existsSync(path.join(p, 'changelog.md'))) continue;
Expand All @@ -92,12 +98,6 @@ It seems that the changelog is not available.
This either means that your Docusaurus setup is misconfigured, or that your GitHub repository contains no releases yet.
`);
}

if (options.changelogFromRoot) {
copyChangelogFromRoot(pathsToCopyChangelog);
} else {
await copyChangelogFromReleases(pathsToCopyChangelog, `${context.siteConfig.organizationName}/${context.siteConfig.projectName}`);
}
} catch (e) {
// eslint-disable-next-line no-console
console.warn(`Changelog page could not be initialized: ${e.message}`);
Expand Down
6 changes: 3 additions & 3 deletions apify-docs-theme/src/theme/DocBreadcrumbs/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Link from '@docusaurus/Link';
import { ThemeClassNames } from '@docusaurus/theme-common';
import {
useSidebarBreadcrumbs,
useHomePageRoute,
} from '@docusaurus/theme-common/internal';
} from '@docusaurus/plugin-content-docs/client';
import { ThemeClassNames } from '@docusaurus/theme-common';
import { useHomePageRoute } from '@docusaurus/theme-common/internal';
import { translate } from '@docusaurus/Translate';
import HomeBreadcrumbItem from '@theme/DocBreadcrumbs/Items/Home';
import clsx from 'clsx';
Expand Down
2 changes: 1 addition & 1 deletion apify-docs-theme/src/theme/DocSidebarItem/Link/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import clsx from 'clsx';
import { ThemeClassNames } from '@docusaurus/theme-common';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import { isActiveSidebarItem } from '@docusaurus/theme-common/internal';
import { isActiveSidebarItem } from '@docusaurus/plugin-content-docs/client';
import Link from '@docusaurus/Link';
import isInternalUrl from '@docusaurus/isInternalUrl';
import IconExternalLink from '@theme/Icon/ExternalLink';
Expand Down
2 changes: 1 addition & 1 deletion apify-docs-theme/src/theme/NavbarItem/ComponentTypes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import HtmlNavbarItem from '@theme/NavbarItem/HtmlNavbarItem';
import DocSidebarNavbarItem from '@theme/NavbarItem/DocSidebarNavbarItem';
import DocsVersionNavbarItem from '@theme/NavbarItem/DocsVersionNavbarItem';
import DocsVersionDropdownNavbarItem from '@theme/NavbarItem/DocsVersionDropdownNavbarItem';
import { useDocsVersion, useLayoutDoc } from '@docusaurus/theme-common/internal';
import { useDocsVersion, useLayoutDoc } from '@docusaurus/plugin-content-docs/client';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import React from 'react';

Expand Down
8 changes: 7 additions & 1 deletion apify-docs-theme/src/theme/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,6 @@ html[data-theme='dark'] .runnable-code-block svg .apify-logo {
min-width: 1.5rem;
display: inline-block;
opacity: .3;
position: sticky;
left: var(--ifm-pre-padding);
}

Expand All @@ -1580,3 +1579,10 @@ html[data-theme='dark'] .runnable-code-block svg .apify-logo {
.apiPage .tsd-panel-header .tsd-anchor-id {
top: -13rem;
}

iframe[src*="youtube"] {
width: 100%;
aspect-ratio: 16/9;
height: auto;
margin-bottom: 1.6rem;
}
Binary file modified apify-docs-theme/static/img/favicon.ico
Binary file not shown.
45 changes: 44 additions & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,39 @@ module.exports = {
organizationName: 'apify',
projectName: 'apify-docs',
scripts: ['/js/custom.js'],
favicon: 'img/favicon.svg',
headTags: [
{
tagName: 'link',
attributes: {
rel: 'icon',
href: '/img/favicon.ico',
type: 'image/x-icon',
size: '48x48',
},
},
{
tagName: 'link',
attributes: {
rel: 'icon',
href: '/img/favicon.svg',
type: 'image/svg+xml',
sizes: 'any',
},
},
// Intercom messenger
process.env.INTERCOM_APP_ID && {
tagName: 'script',
innerHTML: `window.intercomSettings={api_base:"https://api-iam.intercom.io",app_id:"${process.env.INTERCOM_APP_ID}"};`,
attributes: {},
},
// Intercom messenger
process.env.INTERCOM_APP_ID && {
tagName: 'script',
innerHTML: `(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',w.intercomSettings);}else{var d=document;var i=function(){i.c(arguments);};i.q=[];i.c=function(args){i.q.push(args);};w.Intercom=i;var l=function(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/${process.env.INTERCOM_APP_ID}';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);};if(document.readyState==='complete'){l();}else if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()`,
attributes: {},
},
].filter(Boolean),

onBrokenLinks:
/** @type {import('@docusaurus/types').ReportingSeverity} */ ('throw'),
onBrokenMarkdownLinks:
Expand Down Expand Up @@ -125,6 +157,7 @@ module.exports = {
},
],
() => ({
name: 'webpack-loader-fix',
configureWebpack() {
return {
module: {
Expand Down Expand Up @@ -158,6 +191,16 @@ module.exports = {
],
markdown: {
mermaid: true,
parseFrontMatter: async (params) => {
const result = await params.defaultParseFrontMatter(params);

const ogImageURL = new URL('https://apify.com/og-image/docs-article');

ogImageURL.searchParams.set('title', result.frontMatter.title);
result.frontMatter.image ??= ogImageURL.toString();

return result;
},
},
themeConfig: config.themeConfig,
staticDirectories: ['apify-docs-theme/static', 'static'],
Expand Down
10 changes: 5 additions & 5 deletions examples/python-data-scraper/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
# to know when do the results start
if day_offset == 0:
# Get the timezone offset written in the page footer and parse it
tz_description = soup.find_all(class_='wr-c-footer-timezone__item')[1].text
tz_offset_match = re.search(r'([+-]\d\d)(\d\d)', tz_description)
tz_offset_hours = int(tz_offset_match.group(1))
tz_offset_minutes = int(tz_offset_match.group(2))
time_zone_paragraph = soup.find('p', text=lambda x: x and 'All times are' in x)
tz_description = time_zone_paragraph.text
gmt_offset = re.search(r'GMT([+-]\d+)', tz_description)
tz_offset_hours = int(gmt_offset.group(1))

# Get the current date and time at the scraped location
timezone_offset = timedelta(hours=tz_offset_hours, minutes=tz_offset_minutes)
timezone_offset = timedelta(hours=tz_offset_hours)
location_timezone = timezone(timezone_offset)

location_current_datetime = datetime.now(tz=location_timezone)
Expand Down
4 changes: 4 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ server {
rewrite ^/platform/actors/development/testing-and-maintenance$ /platform/actors/development/deployment/automated-tests redirect;
rewrite ^/platform/actors/development/source-code$ /platform/actors/development/deployment/source-types redirect;

# Rename output schema to dataset schema
rewrite ^/platform/actors/development/actor-definition/output-schema$ /platform/actors/development/actor-definition/dataset-schema permanent;
rewrite ^academy/deploying-your-code/output-schema$ /academy/deploying-your-code/dataset-schema permanent;

# Removed pages
# GPT plugins were discontinued April 9th, 2024 - https://help.openai.com/en/articles/8988022-winding-down-the-chatgpt-plugins-beta
rewrite ^/platform/integrations/chatgpt-plugin$ https://blog.apify.com/add-custom-actions-to-your-gpts/ redirect;
Expand Down
Loading

0 comments on commit 45ce16a

Please sign in to comment.