Skip to content

Commit

Permalink
add new website styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Mistobaan committed Mar 20, 2023
1 parent d5a0634 commit c5cfc13
Show file tree
Hide file tree
Showing 44 changed files with 554 additions and 133 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: docs_pages_workflow

on: [pull_request]

permissions:
pull-requests: write

jobs:
build_docs_job:
permissions: write-all
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.8

- name: Get pip cache dir
id: pip-cache
run: |
python -m pip install --upgrade pip
echo "dir={$(pip cache dir)}" >> $GITHUB_OUTPUT
- name: pip cache
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py', '**/requirements.txt', '**/docs/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install docs requirements
run: |
python -m pip install -r docs/requirements.txt
- name: make the sphinx docs
run: |
make -C docs clean
make -C docs html
- uses: readthedocs/actions/preview@v1
with:
project-slug: "trlx"
project-language: "en"
# see: https://github.com/readthedocs/actions/tree/main/preview
# message-template (optional): Text message to be injected by the action in the Pull Request description. It supports the following placeholders to be replaced:
# {docs-pr-index-url}: URL to the root of the documentation for the Pull Request preview.
# platform (optional): Read the Docs Community (community) or Read the Docs for Business (business). (default: community)
# single-version (optional): Set this to 'true' if your project is single version, so we can link to the correct URL. (default: 'false')
21 changes: 14 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-case-conflict
Expand All @@ -18,17 +18,24 @@ repos:
args: [--fix=lf]
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
- id: black
files: ^(trlx|examples|tests|setup.py)/
- repo: https://github.com/pycqa/isort
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- id: isort
name: isort (python)
- repo: https://github.com/pycqa/flake8
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
- id: flake8
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
hooks:
- id: codespell
args: [--ignore-words, dictionary.txt]
additional_dependencies:
- tomli
22 changes: 19 additions & 3 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

build:
os: "ubuntu-20.04"
tools:
python: "3.8"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py
configuration: docs/conf.py
fail_on_warning: false

# Optionally build your docs in additional formats such as PDF and ePub
formats:
- htmlzip

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.9
install:
- requirements: docs/requirements.txt
- requirements: docs/requirements.txt
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
gendoc:
docker build -t trlxgendocs -f docker/docs/Dockerfile .
run:
docker run --rm -it \
-p 8000:8000 \
--entrypoint python trlxgendocs -m http.server 8000 --directory build/docs/build/html

sh:
docker run --rm -it \
-p 8000:8000 \
--entrypoint /bin/bash trlxgendocs
2 changes: 2 additions & 0 deletions dictionary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rouge
sart
18 changes: 18 additions & 0 deletions docker/docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.8-slim

# pip install -r docs/requirements.txt
# sphinx-build -b html docs docs/build/html -j auto
# sphinx-build -b html -D nb_execution_mode=off docs docs/build/html -j auto

RUN python -m pip install --upgrade --no-cache-dir pip
ADD docs/requirements.txt /tmp/requirements.txt
RUN python -m pip install --exists-action=w --no-cache-dir -r /tmp/requirements.txt
RUN apt-get update && apt-get install make imagemagick -y --no-install-recommends \
git \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir /build
WORKDIR /build/
ADD . .
RUN python -m pip install -e .
RUN cd docs && make html
ENTRYPOINT [ "python", "-m", "http.server", "8000" ]
17 changes: 15 additions & 2 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
SOURCEDIR = .
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
Expand All @@ -14,7 +14,20 @@ help:

.PHONY: help Makefile

logo:
convert trlx_logo_red.png -define icon:auto-resize=64,48,32,16 _static/favicon.ico
convert trlx_logo_red.png -resize 16x16 _static/favicon-16x16.png
convert trlx_logo_red.png -resize 57x57 _static/apple-touch-icon.png
convert trlx_logo_red.png -resize 57x57 _static/apple-touch-icon-57x57.png
convert trlx_logo_red.png -resize 72x72 _static/apple-touch-icon-72x72.png
convert trlx_logo_red.png -resize 76x76 _static/apple-touch-icon-76x76.png
convert trlx_logo_red.png -resize 114x114 _static/apple-touch-icon-114x114.png
convert trlx_logo_red.png -resize 120x120 _static/apple-touch-icon-120x120.png
convert trlx_logo_red.png -resize 144x144 _static/apple-touch-icon-144x144.png
convert trlx_logo_red.png -resize 152x152 _static/apple-touch-icon-152x152.png
convert trlx_logo_red.png -resize 180x180 _static/apple-touch-icon-180x180.png

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
%: Makefile logo
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
5 changes: 5 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# How To build the documentation

```bash
make html
```
Binary file added docs/_static/apple-touch-icon-114x114.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/apple-touch-icon-120x120.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/apple-touch-icon-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/apple-touch-icon-152x152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/apple-touch-icon-180x180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/apple-touch-icon-57x57.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/apple-touch-icon-72x72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/apple-touch-icon-76x76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/favicon.ico
Binary file not shown.
23 changes: 23 additions & 0 deletions docs/_static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
:root {
--block-bg-opacity: 0.5;
}

.wy-side-nav-search {
background-color: #fff;
}

.getting-started {
background-color: rgba(78, 150, 253, var(--block-bg-opacity));
}

.user-guides {
background-color: rgba(0, 169, 154, var(--block-bg-opacity));
}

.developer-docs {
background-color: rgba(171, 0, 182, var(--block-bg-opacity));
}

.key-ideas {
border: 0px;
}
2 changes: 2 additions & 0 deletions docs/_templates/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% extends "!layout.html" %}
{% set css_files = css_files + ["_static/style.css"] %}
3 changes: 3 additions & 0 deletions docs/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

`which sphinx-build` -T -E -b html -d _build/doctrees-readthedocs -D language=en . _build/html
Loading

0 comments on commit c5cfc13

Please sign in to comment.