diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000000000..d3f5653e28780 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,48 @@ +name: deploy + +on: + push: + branches: + - main + +permissions: + contents: write + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Configure Git Credentials + run: | + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + + - uses: actions/setup-python@v4 + with: + python-version: 3.x + + - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV + + - uses: actions/cache@v3 + with: + key: mkdocs-material-${{ env.cache_id }} + path: .cache + restore-keys: | + mkdocs-material- + + - name: Install dependencies + run: | + python3 -m pip install --upgrade pip + python3 -m pip install -r requirements.txt + + - run: | + python3 main.py + mkdocs build -f mkdocs.yml + mkdocs build -f mkdocs-en.yml + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./site \ No newline at end of file diff --git a/.prettierignore b/.prettierignore index 761a3209faa0b..2100358d6a917 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,26 +1,26 @@ .idea/ -.github/ -node_modules/ -/solution/CONTEST_README.md -/solution/CONTEST_README_EN.md -/solution/summary.md -/solution/summary_en.md -/solution/README.md -/solution/README_EN.md -/solution/readme_template.md -/solution/readme_template_en.md -/solution/problem_readme_template.md -/solution/problem_readme_template_en.md -/solution/bash_problem_readme_template.md -/solution/bash_problem_readme_template_en.md -/solution/0100-0199/0177.Nth Highest Salary/Solution.sql -/solution/0100-0199/0178.Rank Scores/Solution2.sql -/solution/0500-0599/0586.Customer Placing the Largest Number of Orders/Solution2.sql -/solution/1400-1499/1454.Active Users/Solution.sql -/solution/1600-1699/1635.Hopper Company Queries I/Solution.sql -/solution/2100-2199/2118.Build the Equation/Solution.sql -/solution/2100-2199/2175.The Change in Global Rankings/Solution.sql -/solution/2200-2299/2205.The Number of Users That Are Eligible for Discount/Solution.sql -/solution/2200-2299/2230.The Users That Are Eligible for Discount/Solution.sql -/solution/2200-2299/2252.Dynamic Pivoting of a Table/Solution.sql -/solution/2200-2299/2253.Dynamic Unpivoting of a Table/Solution.sql \ No newline at end of file +.DS_Store +.vscode +.temp +.cache +/node_modules +/solution/result.json +/solution/contest.json +/solution/contest_list.json +/solution/raw.json +/lcof/lcof.json +/lcof/lcof_list.json +/lcci/lcci.json +/solution/__pycache__ +/solution/.env +*.iml + +site +/docs/lc +/docs/lcof +/docs/lcci +/docs/lcof2 +/docs/lcp +/docs/lcs +/docs-en/lc +/docs-en/lcci \ No newline at end of file diff --git a/main.py b/main.py index 51e5bb0bcb007..68109ebb29b3d 100644 --- a/main.py +++ b/main.py @@ -66,7 +66,6 @@ def get_paths(dirs: str, m: int): - dirs = 'main' + os.sep + dirs paths = [] for root, _, files in os.walk(dirs): for file in files: @@ -77,12 +76,12 @@ def get_paths(dirs: str, m: int): dirs_mapping = { - "solution": ("lc", 5), - "lcof": ("lcof", 4), - "lcof2": ("lcof2", 4), - "lcci": ("lcci", 4), - "lcp": ("lcp", 4), - "lcs": ("lcs", 4), + "solution": ("lc", 4), + "lcof": ("lcof", 3), + "lcof2": ("lcof2", 3), + "lcci": ("lcci", 3), + "lcp": ("lcp", 3), + "lcs": ("lcs", 3), } dirs = ["solution", "lcof", "lcof2", "lcci", "lcp", "lcs"] @@ -102,6 +101,12 @@ def get_paths(dirs: str, m: int): for p in sorted(get_paths(dir, m)): with open(p, "r", encoding="utf-8") as f: content = f.read() + + # [中文文档](/lcci/01.01.Is%20Unique/README.md) + # 正则匹配 [中文文档](xxx) 并且移除 + content = re.sub(r"\[中文文档]\((.*?)\)", "", content) + content = re.sub(r"\[English Version]\((.*?)\)", "", content) + title = content[content.find("[") + 1 : content.find("]")] dot = title.find(".") if dir != "lcci" else title.rfind(".") num = ( diff --git a/mkdocs-en.yml b/mkdocs-en.yml index 5c6db572e33ed..e8d4d44028a2b 100644 --- a/mkdocs-en.yml +++ b/mkdocs-en.yml @@ -1,9 +1,12 @@ INHERIT: mkdocs.yml site_description: LeetCode solutions in any programming language +site_dir: site/en docs_dir: docs-en - - - +theme: + language: en + font: + text: Roboto + code: Roboto Mono nav: - LeetCode: diff --git a/mkdocs.yml b/mkdocs.yml index 114b38637ddfe..71d4e2276da93 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -2,6 +2,7 @@ site_name: LeetCode Wiki site_url: https://doocs.github.io/leetcode site_description: 多种编程语言实现 LeetCode、《剑指 Offer(第 2 版)》、《程序员面试金典(第 6 版)》题解 site_author: yanglbme +site_dir: site docs_dir: docs repo_name: doocs/leetcode repo_url: https://github.com/doocs/leetcode @@ -59,7 +60,7 @@ theme: plugins: - search: - separator: '[\s\-,:!=\[\]()"/]+|(?!\b)(?=[A-Z][a-z])|\.(?!\d)|&[lg]t;' + separator: '[\s\u200b\-_,:!=\[\]()"`/]+|\.(?!\d)|&[lg]t;|(?!\b)(?=[A-Z][a-z])' markdown_extensions: - pymdownx.superfences @@ -91,8 +92,6 @@ extra: lang: zh - - nav: - LeetCode: - 1. 两数之和: lc/1.md