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

Add Windows support to preview with minimal changes & CI support #351

Merged
merged 2 commits into from
Mar 2, 2023
Merged
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
10 changes: 7 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ on: [pull_request]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
Expand All @@ -13,7 +17,7 @@ jobs:
python-version: 3.7
- name: Install Python dependencies
run: |
pip install -e .[all]
pip install -e ".[all]"
pip install git+https://github.com/huggingface/transformers
- name: Run Tests
run: make test
run: python -m pytest -n 1 --dist=loadfile -s -v ./tests/
3 changes: 2 additions & 1 deletion kit/src/routes/endpoints/toc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from "path";
import fs from "fs";
import yaml from "js-yaml";
import { fileURLToPath } from "url";

export interface RawChapter {
title: string;
Expand All @@ -23,7 +24,7 @@ const flattener = (_flatChapters: RawChapter[], chapter: RawChapter): RawChapter
};

export async function get() {
const filepath = path.join(import.meta.url.replace('file://', ''), '../..', '_toctree.yml');
const filepath = path.join(fileURLToPath(import.meta.url), '../..', '_toctree.yml');
const content = (await fs.promises.readFile(filepath)).toString("utf-8");

const chapters: RawChapter[] = yaml.load(content) as RawChapter[];
Expand Down
4 changes: 3 additions & 1 deletion src/doc_builder/build_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def check_toc_integrity(doc_folder, output_dir):
output_dir (`str` or `os.PathLike`): The folder where the doc is built.
"""
output_dir = Path(output_dir)
doc_files = [str(f.relative_to(output_dir).with_suffix("").as_posix()) for f in output_dir.glob("**/*.mdx")]
doc_files = [str(f.relative_to(output_dir).with_suffix("")) for f in output_dir.glob("**/*.mdx")]

toc_file = Path(doc_folder) / "_toctree.yml"
with open(toc_file, "r", encoding="utf-8") as f:
Expand All @@ -489,6 +489,8 @@ def check_toc_integrity(doc_folder, output_dir):
# Toc has some nested sections in the API doc for instance, so we recurse.
toc.extend([sec for sec in part["sections"] if "sections" in sec])

# normalize paths to current OS
toc_sections = [str(Path(path)) for path in toc_sections]
files_not_in_toc = [f for f in doc_files if f not in toc_sections]
doc_config = get_doc_config()
disable_toc_check = getattr(doc_config, "disable_toc_check", False)
Expand Down
3 changes: 3 additions & 0 deletions src/doc_builder/commands/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import argparse
import os
import platform
import shutil
import subprocess
import tempfile
Expand Down Expand Up @@ -135,6 +136,7 @@ def start_sveltekit_dev(tmp_dir, env, args):
check=True,
encoding="utf-8",
cwd=working_dir,
shell=platform.system() == "Windows",
)

# start sveltekit in dev mode
Expand All @@ -144,6 +146,7 @@ def start_sveltekit_dev(tmp_dir, env, args):
encoding="utf-8",
cwd=working_dir,
env=env,
shell=platform.system() == "Windows",
)


Expand Down