parent
af50e6613f
commit
7b2866b596
@ -0,0 +1,42 @@
|
||||
# This is a basic workflow to help you get started with Actions
|
||||
|
||||
name: CI
|
||||
|
||||
# Controls when the action will run. Triggers the workflow on push or pull request
|
||||
# events but only for the master branch
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
workflow_dispatch:
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
# This workflow contains a single job called "build"
|
||||
build:
|
||||
# The type of runner that the job will run on
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Python 3.x
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.x
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
|
||||
- name: Update dir
|
||||
run: python generate.py
|
||||
|
||||
- name: Deploy docs
|
||||
uses: mhausenblas/mkdocs-deploy-gh-pages@nomaterial
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@ -0,0 +1,15 @@
|
||||
/.gradle
|
||||
/.idea
|
||||
/build
|
||||
*/build
|
||||
/captures
|
||||
/.cxx
|
||||
*/.cxx
|
||||
/.externalNativeBuild
|
||||
|
||||
._*
|
||||
*.iml
|
||||
.DS_Store
|
||||
local.properties
|
||||
|
||||
docs/
|
@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import shutil
|
||||
from urllib.parse import quote
|
||||
|
||||
EXCLUDE_DIRS = ['.git', 'docs', '.vscode', 'overrides', '.github', 'script']
|
||||
README_MD = ['README.md', 'readme.md', 'index.md']
|
||||
INDEX_FILE = 'index.md'
|
||||
|
||||
IMAGE_EXTS = ['jpg', 'png', 'svg', 'jpeg', 'gif', 'webp']
|
||||
IMAGE_URL_PREFIX = 'https://github.com/beiyuouo/hainanu-course-comments/blob/main/'
|
||||
BIN_URL_PREFIX = 'https://github.com/beiyuouo/hainanu-course-comments/raw/main/'
|
||||
|
||||
|
||||
def list_image(course: str):
|
||||
imagelist_text = f'# {os.path.basename(course)}\n'
|
||||
|
||||
for root, dirs, files in os.walk(course):
|
||||
files.sort()
|
||||
readme_path = '{}/{}'.format(root, INDEX_FILE)
|
||||
level = root.replace(course, '').count(os.sep)
|
||||
for f in files:
|
||||
if f.split('.')[-1].lower() in IMAGE_EXTS:
|
||||
imagelist_text += '{{ width="200" }}\n'.format(os.path.join(f))
|
||||
return imagelist_text, readme_path
|
||||
|
||||
|
||||
def generate_md(course: str, filelist_texts: str, readme_path: str, topic: str):
|
||||
final_texts = ['\n\n'.encode(), filelist_texts.encode()]
|
||||
topic_path = os.path.join('docs', topic)
|
||||
if not os.path.isdir(topic_path):
|
||||
os.mkdir(topic_path)
|
||||
with open(os.path.join(topic_path, '{}.md'.format(course)), 'wb') as file:
|
||||
file.writelines(final_texts)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if os.path.exists('docs'):
|
||||
shutil.rmtree('docs')
|
||||
if not os.path.isdir('docs'):
|
||||
os.mkdir('docs')
|
||||
|
||||
topics = list(
|
||||
filter(lambda x: os.path.isdir(x) and (x not in EXCLUDE_DIRS),
|
||||
os.listdir('.'))) # list topics
|
||||
|
||||
for topic in topics:
|
||||
topic_path = os.path.join('.', topic)
|
||||
target_path = os.path.join('docs', topic)
|
||||
|
||||
if os.path.exists(target_path):
|
||||
shutil.rmtree(target_path)
|
||||
shutil.copytree(topic_path, target_path)
|
||||
|
||||
topic_path = os.path.join(".", topic)
|
||||
imagelist_text, readme_path = list_image(topic_path)
|
||||
generate_md('index', imagelist_text, readme_path, topic)
|
||||
|
||||
with open('README.md', 'rb') as file:
|
||||
mainreadme_lines = file.readlines()
|
||||
|
||||
with open('docs/index.md', 'wb') as file:
|
||||
file.writelines(mainreadme_lines)
|
@ -0,0 +1,28 @@
|
||||
site_name: Anime-Girls-Holding-Programming-Books
|
||||
|
||||
theme:
|
||||
name: material
|
||||
custom_dir: overrides
|
||||
features:
|
||||
- navigation.indexes
|
||||
|
||||
repo_url: https://github.com/cat-milk/Anime-Girls-Holding-Programming-Books
|
||||
|
||||
markdown_extensions:
|
||||
- def_list
|
||||
- pymdownx.tasklist:
|
||||
custom_checkbox: true
|
||||
- attr_list
|
||||
- md_in_html
|
||||
- pymdownx.emoji:
|
||||
emoji_index: !!python/name:materialx.emoji.twemoji
|
||||
emoji_generator: !!python/name:materialx.emoji.to_svg
|
||||
|
||||
plugins:
|
||||
- search:
|
||||
lang:
|
||||
- en
|
||||
extra:
|
||||
analytics:
|
||||
provider: google
|
||||
property: UA-145083103-1
|
@ -0,0 +1,17 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block disqus %}
|
||||
<script src="https://giscus.app/client.js"
|
||||
data-repo="beiyuouo/mkdocs-emoticon-gallery"
|
||||
data-repo-id="R_kgDOGSn1gw"
|
||||
data-category="General"
|
||||
data-category-id="DIC_kwDOGSn1g84B_n2h"
|
||||
data-mapping="pathname"
|
||||
data-reactions-enabled="1"
|
||||
data-emit-metadata="0"
|
||||
data-theme="light"
|
||||
data-lang="en"
|
||||
crossorigin="anonymous"
|
||||
async>
|
||||
</script>
|
||||
{% endblock %}
|
@ -0,0 +1,3 @@
|
||||
mkdocs==1.2.3
|
||||
mkdocs-material==7.3.6
|
||||
pymdown-extensions
|
Loading…
Reference in new issue