lightweight-versioned-gitlab-pages


Namelightweight-versioned-gitlab-pages JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://gitlab.com/brainelectronics/lightweight-versioned-gitlab-pages
SummaryEnable GitLab pages to provide documentation for multiple versions
upload_time2023-02-07 22:44:05
maintainer
docs_urlNone
authorbrainelectronics
requires_python>=3.7, <4
license
keywords gitlab version pages versioning generator documentation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Lightweight Versioned GitLab Pages

[![Downloads](https://pepy.tech/badge/lightweight-versioned-gitlab-pages)](https://pepy.tech/project/lightweight-versioned-gitlab-pages)
[![pipeline status](https://gitlab.com/brainelectronics/lightweight-versioned-gitlab-pages/badges/main/pipeline.svg)](https://gitlab.com/brainelectronics/lightweight-versioned-gitlab-pages/-/commits/main)
[![Documentation Status](https://readthedocs.org/projects/lightweight-versioned-gitlab-pages/badge/?version=latest)](https://lightweight-versioned-gitlab-pages.readthedocs.io/en/latest/?badge=latest)
[![coverage report](https://gitlab.com/brainelectronics/lightweight-versioned-gitlab-pages/badges/main/coverage.svg)](https://gitlab.com/brainelectronics/lightweight-versioned-gitlab-pages/-/commits/main)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/lightweight-versioned-gitlab-pages)
[![License: MIT](https://img.shields.io/gitlab/license/brainelectronics/lightweight-versioned-gitlab-pages?color=green)](https://opensource.org/licenses/MIT)

Generate index page with links to all previously archived folders during a tag
build.

This repo developed in and mirrored from [GitLab brainelectronics](https://gitlab.com/brainelectronics/lightweight-versioned-gitlab-pages).
Please raise your issues and submit your pull requests/merge requests there.

---------------

## Installation

```bash
pip install lightweight-versioned-gitlab-pages
```

## Documentation

📚 The latest documentation is available at

- [Lightweight versioned GitLab Pages GitLab Pages](https://brainelectronics.gitlab.io/lightweight-versioned-gitlab-pages)
- [Lightweight versioned GitLab Pages ReadTheDocs](https://lightweight-versioned-gitlab-pages.readthedocs.io/en/latest/)

## Reasoning

GitLab offers the possibility to create or place a folder named `public` in the
root of the repo. The contents of this folder are then displayed by
[GitLab pages](https://docs.gitlab.com/ee/user/project/pages/) and is
accessible from outside the repo via a custom URL.

For this package, the URL is
[`https://brainelectronics.gitlab.io/-/lightweight-versioned-gitlab-pages`](https://brainelectronics.gitlab.io/lightweight-versioned-gitlab-pages).
This is also the location of the (latest) documentation for this package.
Since only only one "thing" can be displayed there, usually only the most
recent content is available at this URL. This is where this package is supposed to help.

## Usage

It is assumed that only tagged states of the documentation or other content
will be displayed on the GitLab Pages web page, see also chapter Limitations.

The script will use an API token to make all requests through the
[`python-gitlab`](https://python-gitlab.readthedocs.io/en/stable/) package.
This token must be specified via the `--private-token` argument. The token can
be generated via `Settings -> Access Tokens` and requires `api` scope.

In addition, the unique project ID must be specified with `--project-id`.
This ID can be found at the top of each repo. For this repository it is
`43170198`.

The last mandatory parameter is `--job-name`. This is the name of the job
that generates, for example, the documentation or other content that will be
displayed via the GitLab pages web page.

The generated `index.html` is placed in a folder named `public`. By default
this folder is created in the same directory from which this script is called.
A different destination folder can be specified with `--output-dir`. The folder
does not have to exist, it and its possibly needed parent directories will be
created if necessary.

If a self-hosted GitLab is used, the URL to the instance can be specified with
`--url` to not restrict this package to GitLab.com only.

### Help

```bash
generate-versioned-pages --help
```

### Generate lightweight versioned pages

The following command will create a folder named `public` at the current
location and place an index HTML file inside.

This index file contains a simple list of
[Bootstrap cards](https://getbootstrap.com/docs/5.0/components/card/)
with all previously built tags and the URL to the public pages archive files.

```bash
generate-versioned-pages \
--private_token asdf-carlTheLamaIsHere \
--project-id 43170198 \
--job-name pages
```

Then use this generated folder in the `pages` job. The job configuration in the
file `.gitlab-ci.yml` can look like the following example and is used in that
way for this package.

```yaml
pages:
  stage: deploy
  before_script:
    - pip install lightweight-versioned-gitlab-pages
  script:
    - generate-versioned-pages
      --private_token ${GITLAB_API_TOKEN}
      --project-id ${CI_PROJECT_ID}
      --job-name generate-docs
  artifacts:
    expire_in: never
    paths:
      - public
  only:
    - main
```

## How it works

First, the available tags of the repo are requested/gathered by the
[get_project_tags](lightweight_versioned_gitlab_pages.generate.get_project_tags)
function. For each tag, the corresponding pipeline job is requested based on
the provided `job-name` argument. The job status must be successful to avoid
erroneous or currently generated artifacts. For each job, the URL to the index
file of the `public` folder is generated, see
[get_artifact_url](lightweight_versioned_gitlab_pages.generate.get_artifact_url)
The generated list of
[TagInfos](lightweight_versioned_gitlab_pages.generate.TagInfo) will then be
used to create a simple `index.html` file inside a generated `public` folder,
unless it is to be generated elsewhere.
The template is rendered with [Jinja2](https://github.com/pallets/jinja/).

## Limitations

- Only links to tagged and archived data of `public` folders are included in
the index
- Job artifacts must be publicly accessible
    - Make sure that `CI/CD` is activated and set to `Everyone With Access` at
    `Settings -> General -> Visibility`

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/brainelectronics/lightweight-versioned-gitlab-pages",
    "name": "lightweight-versioned-gitlab-pages",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7, <4",
    "maintainer_email": "",
    "keywords": "gitlab,version,pages,versioning,generator,documentation",
    "author": "brainelectronics",
    "author_email": "jonas@brainelectronics.de",
    "download_url": "https://files.pythonhosted.org/packages/05/fc/cba523b62eedf3ecf749d3cd20abd8e3b864ac71e03871e9fb7f426fece7/lightweight-versioned-gitlab-pages-0.2.2.tar.gz",
    "platform": null,
    "description": "# Lightweight Versioned GitLab Pages\n\n[![Downloads](https://pepy.tech/badge/lightweight-versioned-gitlab-pages)](https://pepy.tech/project/lightweight-versioned-gitlab-pages)\n[![pipeline status](https://gitlab.com/brainelectronics/lightweight-versioned-gitlab-pages/badges/main/pipeline.svg)](https://gitlab.com/brainelectronics/lightweight-versioned-gitlab-pages/-/commits/main)\n[![Documentation Status](https://readthedocs.org/projects/lightweight-versioned-gitlab-pages/badge/?version=latest)](https://lightweight-versioned-gitlab-pages.readthedocs.io/en/latest/?badge=latest)\n[![coverage report](https://gitlab.com/brainelectronics/lightweight-versioned-gitlab-pages/badges/main/coverage.svg)](https://gitlab.com/brainelectronics/lightweight-versioned-gitlab-pages/-/commits/main)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/lightweight-versioned-gitlab-pages)\n[![License: MIT](https://img.shields.io/gitlab/license/brainelectronics/lightweight-versioned-gitlab-pages?color=green)](https://opensource.org/licenses/MIT)\n\nGenerate index page with links to all previously archived folders during a tag\nbuild.\n\nThis repo developed in and mirrored from [GitLab brainelectronics](https://gitlab.com/brainelectronics/lightweight-versioned-gitlab-pages).\nPlease raise your issues and submit your pull requests/merge requests there.\n\n---------------\n\n## Installation\n\n```bash\npip install lightweight-versioned-gitlab-pages\n```\n\n## Documentation\n\n\ud83d\udcda The latest documentation is available at\n\n- [Lightweight versioned GitLab Pages GitLab Pages](https://brainelectronics.gitlab.io/lightweight-versioned-gitlab-pages)\n- [Lightweight versioned GitLab Pages ReadTheDocs](https://lightweight-versioned-gitlab-pages.readthedocs.io/en/latest/)\n\n## Reasoning\n\nGitLab offers the possibility to create or place a folder named `public` in the\nroot of the repo. The contents of this folder are then displayed by\n[GitLab pages](https://docs.gitlab.com/ee/user/project/pages/) and is\naccessible from outside the repo via a custom URL.\n\nFor this package, the URL is\n[`https://brainelectronics.gitlab.io/-/lightweight-versioned-gitlab-pages`](https://brainelectronics.gitlab.io/lightweight-versioned-gitlab-pages).\nThis is also the location of the (latest) documentation for this package.\nSince only only one \"thing\" can be displayed there, usually only the most\nrecent content is available at this URL. This is where this package is supposed to help.\n\n## Usage\n\nIt is assumed that only tagged states of the documentation or other content\nwill be displayed on the GitLab Pages web page, see also chapter Limitations.\n\nThe script will use an API token to make all requests through the\n[`python-gitlab`](https://python-gitlab.readthedocs.io/en/stable/) package.\nThis token must be specified via the `--private-token` argument. The token can\nbe generated via `Settings -> Access Tokens` and requires `api` scope.\n\nIn addition, the unique project ID must be specified with `--project-id`.\nThis ID can be found at the top of each repo. For this repository it is\n`43170198`.\n\nThe last mandatory parameter is `--job-name`. This is the name of the job\nthat generates, for example, the documentation or other content that will be\ndisplayed via the GitLab pages web page.\n\nThe generated `index.html` is placed in a folder named `public`. By default\nthis folder is created in the same directory from which this script is called.\nA different destination folder can be specified with `--output-dir`. The folder\ndoes not have to exist, it and its possibly needed parent directories will be\ncreated if necessary.\n\nIf a self-hosted GitLab is used, the URL to the instance can be specified with\n`--url` to not restrict this package to GitLab.com only.\n\n### Help\n\n```bash\ngenerate-versioned-pages --help\n```\n\n### Generate lightweight versioned pages\n\nThe following command will create a folder named `public` at the current\nlocation and place an index HTML file inside.\n\nThis index file contains a simple list of\n[Bootstrap cards](https://getbootstrap.com/docs/5.0/components/card/)\nwith all previously built tags and the URL to the public pages archive files.\n\n```bash\ngenerate-versioned-pages \\\n--private_token asdf-carlTheLamaIsHere \\\n--project-id 43170198 \\\n--job-name pages\n```\n\nThen use this generated folder in the `pages` job. The job configuration in the\nfile `.gitlab-ci.yml` can look like the following example and is used in that\nway for this package.\n\n```yaml\npages:\n  stage: deploy\n  before_script:\n    - pip install lightweight-versioned-gitlab-pages\n  script:\n    - generate-versioned-pages\n      --private_token ${GITLAB_API_TOKEN}\n      --project-id ${CI_PROJECT_ID}\n      --job-name generate-docs\n  artifacts:\n    expire_in: never\n    paths:\n      - public\n  only:\n    - main\n```\n\n## How it works\n\nFirst, the available tags of the repo are requested/gathered by the\n[get_project_tags](lightweight_versioned_gitlab_pages.generate.get_project_tags)\nfunction. For each tag, the corresponding pipeline job is requested based on\nthe provided `job-name` argument. The job status must be successful to avoid\nerroneous or currently generated artifacts. For each job, the URL to the index\nfile of the `public` folder is generated, see\n[get_artifact_url](lightweight_versioned_gitlab_pages.generate.get_artifact_url)\nThe generated list of\n[TagInfos](lightweight_versioned_gitlab_pages.generate.TagInfo) will then be\nused to create a simple `index.html` file inside a generated `public` folder,\nunless it is to be generated elsewhere.\nThe template is rendered with [Jinja2](https://github.com/pallets/jinja/).\n\n## Limitations\n\n- Only links to tagged and archived data of `public` folders are included in\nthe index\n- Job artifacts must be publicly accessible\n    - Make sure that `CI/CD` is activated and set to `Everyone With Access` at\n    `Settings -> General -> Visibility`\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Enable GitLab pages to provide documentation for multiple versions",
    "version": "0.2.2",
    "split_keywords": [
        "gitlab",
        "version",
        "pages",
        "versioning",
        "generator",
        "documentation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f70213a5c251e910b2b7e22f106e58f8c2e351252900b8bcbe78a07d08e988bc",
                "md5": "32715ba92d07c05cdaa9ae4053a72aa6",
                "sha256": "cbc0a013282f04a56523dde813f7d1ac7beacdf6c37ce93ceb6b22fc2afe8b81"
            },
            "downloads": -1,
            "filename": "lightweight_versioned_gitlab_pages-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "32715ba92d07c05cdaa9ae4053a72aa6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7, <4",
            "size": 10256,
            "upload_time": "2023-02-07T22:44:04",
            "upload_time_iso_8601": "2023-02-07T22:44:04.169801Z",
            "url": "https://files.pythonhosted.org/packages/f7/02/13a5c251e910b2b7e22f106e58f8c2e351252900b8bcbe78a07d08e988bc/lightweight_versioned_gitlab_pages-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "05fccba523b62eedf3ecf749d3cd20abd8e3b864ac71e03871e9fb7f426fece7",
                "md5": "f4b710238708cc816df38bdb49e2167a",
                "sha256": "e38b83f4b5f30d104b4153c108a3340501b3385cbb30db55623d37e5804463de"
            },
            "downloads": -1,
            "filename": "lightweight-versioned-gitlab-pages-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "f4b710238708cc816df38bdb49e2167a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7, <4",
            "size": 15123,
            "upload_time": "2023-02-07T22:44:05",
            "upload_time_iso_8601": "2023-02-07T22:44:05.974012Z",
            "url": "https://files.pythonhosted.org/packages/05/fc/cba523b62eedf3ecf749d3cd20abd8e3b864ac71e03871e9fb7f426fece7/lightweight-versioned-gitlab-pages-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-07 22:44:05",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "gitlab_user": "brainelectronics",
    "gitlab_project": "lightweight-versioned-gitlab-pages",
    "lcname": "lightweight-versioned-gitlab-pages"
}
        
Elapsed time: 0.03757s