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 documentation with Jupyterlite demo #8

Merged
merged 10 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 8 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
14 changes: 14 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2

build:
os: "ubuntu-22.04"
tools:
python: "mambaforge-4.10"
nodejs: "18"

sphinx:
builder: html
configuration: docs/conf.py

conda:
environment: docs-environment.yml
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# litegitpuller

[![Github Actions Status](https://github.com/jupyterlite/litegitpuller/workflows/Build/badge.svg)](https://github.com/jupyterlite/litegitpuller/actions/workflows/build.yml)[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jupyterlite/litegitpuller/main?urlpath=lab)
[![Github Actions Status](https://github.com/jupyterlite/litegitpuller/workflows/Build/badge.svg)](https://github.com/jupyterlite/litegitpuller/actions/workflows/build.yml)

A jupyterlite extension to automate cloning of a github repository.

## Docs

https://litegitpuller.readthedocs.io/en/latest/index.html

## Requirements

- JupyterLab >= 3.0
Expand Down
8 changes: 8 additions & 0 deletions docs-environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: litegitpuller-docs
channels:
- conda-forge
dependencies:
- pip
- jupyterlite-xeus-python >=0.9.0,<0.10.0
- pip:
- .[docs]
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally we should be able to avoid using a Makefile, to make things simpler.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I updated the PR.
Can you explain when this additional hatch script for documentation is triggered ?
As far as I understand readthedoc build the documentation itself for PRs and branch.

#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

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

project = 'litegitpuller'
copyright = '2023, Jupyter Development Team'
author = 'Jupyter Development Team'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
'jupyterlite_sphinx',
'myst_parser',
]

templates_path = ['_templates']
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'pydata_sphinx_theme'
html_static_path = ['_static']

jupyterlite_bind_ipynb_suffix = False
39 changes: 39 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# litegitpuller

A Jupyterlab/jupyterlite extension to fetch github repositories.

As for [nbgitpuller](https://github.com/jupyterhub/nbgitpuller), information about the repository to fetch has to be set in the URL.

```{eval-rst}
.. jupyterlite::
:width: 100%
:height: 600px
:prompt: Try JupyterLite!
:prompt_color: #00aa42
:search_params: ["branch", "repo", "urlpath"]
```

## Parameters

The parameters to provide must be formatted as in `nbgitpuller`.\
They can be generated with [nbgitpuller link generator](https://nbgitpuller.readthedocs.io/en/latest/link.html).

Currently the allowed parameters are:

- `repo`: the github repository to fetch
- `branch`: the branch of the repository to fetch
- `urlpath`: the path to a notebook file to open (relative to the root of the repository).

## Limitations

Fetching a repository uses the unauthenticated Github API to fetch each file, with a capacity of 60 files per hour
see [github API](https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limits-for-requests-from-personal-accounts).

Do not expect to fetch a large repository with it.

## Try it

It can be tried with the current documentation, by providing parameters in the current URL of the documentation.

As an example the following URL will reload the current page with some repo parameters:\
<https://litegitpuller.readthedocs.io/en/latest/index.html?repo=https%3A%2F%2Fgithub.com%2Fbrichet%2Ftesting-repo&urlpath=tree%2Ftesting-repo%2Fnotebooks%2Fsimple.ipynb&branch=main>
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ dependencies = [
]
dynamic = ["version", "description", "authors", "urls", "keywords"]

[project.optional-dependencies]
docs = [
"jupyterlite-sphinx>=0.9.2",
"jupyterlite-xeus-python>=0.9.0,<0.10.0",
"myst-parser",
"pydata_sphinx_theme",
"sphinx>=4"
]

[tool.hatch.version]
source = "nodejs"

Expand Down
Loading