Skip to content

Commit

Permalink
Merge pull request #45 from ImperialCollegeLondon/mkdocs
Browse files Browse the repository at this point in the history
Add configuration for `mkdocs`
  • Loading branch information
Thomas-Rowlands authored Oct 2, 2024
2 parents 0b3f383 + 528228c commit d9eddbe
Show file tree
Hide file tree
Showing 10 changed files with 1,102 additions and 46 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Deploy to GitHub Pages

on:
push:
branches: [main]
# release:
# types: [published]

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: pages
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
timeout-minutes: 15
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: 1.8.3
- uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: poetry
- name: Install dependencies
run: poetry install
- name: Build docs with MkDocs
run: poetry run mkdocs build --strict
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: site
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ We present a JSON format for sharing table content and metadata that is based on

**Config files**

If you wish to contribute or edit a config file then please follow the instructions in the [config guide](Tutorial/config_tutorial.md)
If you wish to contribute or edit a config file then please follow the instructions in the [config guide](docs/config_tutorial.md).

Auto-CORPus is able to parse HTML from different publishers, which utilise different HTML structures and naming conventions. This is made possible by the inclusion of config files which tell Auto-CORPus how to identify specific sections of the article/table within the source HTML. We have supplied a config template along with example config files for [PubMed Central](configs/config_pmc.json), [Plos Genetics](configs/config_plos_genetics.json) and [Nature Genetics](configs/config_nature_genetics.json) in the [configs](configs) directory. Documentation on how to create and modify config files is available within the [Tutorial](Tutorial) directory. Users of Auto-CORPus can submit their own config files for different sources via the [issues](https://github.com/omicsNLP/Auto-CORPus/issues) tab.
Auto-CORPus is able to parse HTML from different publishers, which utilise different HTML structures and naming conventions. This is made possible by the inclusion of config files which tell Auto-CORPus how to identify specific sections of the article/table within the source HTML. We have supplied a config template along with example config files for [PubMed Central](configs/config_pmc.json), [Plos Genetics](configs/config_plos_genetics.json) and [Nature Genetics](configs/config_nature_genetics.json) in the [configs](configs) directory. Users of Auto-CORPus can submit their own config files for different sources via the [issues](https://github.com/omicsNLP/Auto-CORPus/issues) tab.

**Auto-CORPus recognises 2 types of input file which are:**

Expand Down
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions docs/gen_ref_nav.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Generate the code reference pages and navigation."""

from pathlib import Path

import mkdocs_gen_files

nav = mkdocs_gen_files.Nav()

for path in sorted(Path("src").glob("**/*.py")):
module_path = path.relative_to(".").with_suffix("")
doc_path = path.relative_to(".").with_suffix(".md")
full_doc_path = Path("reference", doc_path)

parts = list(module_path.parts)
if ".array_cache" in parts:
continue
elif parts[-1] == "__init__":
parts = parts[:-1]
doc_path = doc_path.with_name("index.md")
full_doc_path = full_doc_path.with_name("index.md")
elif parts[-1] == "__main__":
continue
nav[parts] = doc_path

with mkdocs_gen_files.open(full_doc_path, "w") as fd:
ident = ".".join(parts)
print("::: " + ident, file=fd)

mkdocs_gen_files.set_edit_path(full_doc_path, Path("../") / path)

with mkdocs_gen_files.open("reference/SUMMARY.md", "w") as nav_file:
nav_file.writelines(nav.build_literate_nav())
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Auto-CORPus

This is the main page for the Auto-CORPus documentation.
27 changes: 27 additions & 0 deletions docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* Indentation. */
div.doc-contents:not(.first) {
padding-left: 25px;
border-left: .05rem solid var(--md-typeset-table-color);
}

/* Mark external links as such. */
a.autorefs-external::after {
/* https://primer.style/octicons/arrow-up-right-24 */
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="rgb(0, 0, 0)" d="M18.25 15.5a.75.75 0 00.75-.75v-9a.75.75 0 00-.75-.75h-9a.75.75 0 000 1.5h7.19L6.22 16.72a.75.75 0 101.06 1.06L17.5 7.56v7.19c0 .414.336.75.75.75z"></path></svg>');
content: ' ';

display: inline-block;
position: relative;
top: 0.1em;
margin-left: 0.2em;
margin-right: 0.1em;

height: 1em;
width: 1em;
border-radius: 100%;
background-color: var(--md-typeset-a-color);
}

a.autorefs-external:hover::after {
background-color: var(--md-accent-fg-color);
}
41 changes: 41 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
site_name: Auto-CORPus
watch: [src]

theme:
name: material

extra_css:
- stylesheets/extra.css

markdown_extensions:
- admonition
- pymdownx.snippets:
check_paths: true
- toc:
permalink: ¤

plugins:
- search
- gen-files:
scripts:
- docs/gen_ref_nav.py
- literate-nav:
nav_file: SUMMARY.md
- section-index
- mkdocstrings:
default_handler: python
handlers:
python:
options:
# docstring_style: sphinx
show_source: true
show_root_heading: true
show_category_heading: true
merge_init_into_class: true

nav:
- Auto-CORPus documentation: index.md
- How to create/edit a config file: config_tutorial.md
- Use of data elements: data_elements.md
# defer to gen-files + literate-nav
- Code Reference: reference/
Loading

0 comments on commit d9eddbe

Please sign in to comment.