Code Monkey home page Code Monkey logo

absaoss / living-doc-generator Goto Github PK

View Code? Open in Web Editor NEW
0.0 8.0 0.0 459 KB

"living-doc-generator: A GitHub Action designed to data-mine GitHub repositories for issues containing project documentation (e.g., tagged with feature-related labels). This action automatically generates fresh documentation in markdown format, providing detailed feature overview pages and in-depth feature descriptions.

License: Apache License 2.0

Python 95.75% JavaScript 4.25%
auto-docs auto-documentation developer-tool documentation-generator feature-documentation github-action issue-tracking markdown-generator open-source project-management

living-doc-generator's Introduction

Living Documentation Generator

A tool designed to data-mine GitHub repositories for issues containing project documentation (e.g. tagged with feature-related labels). This tool automatically generates comprehensive living documentation in Markdown format, providing detailed feature overview pages and in-depth feature descriptions.

Motivation

Addresses the need for continuously updated documentation accessible to all team members and stakeholders. Achieves this by extracting information directly from GitHub issues and integrating this functionality to deliver real-time, markdown-formatted output. Ensures everyone has the most current project details, fostering better communication and efficiency throughout development.

Usage

Prerequisites

Before we begin, ensure you have a GitHub Token with permission to fetch repository data such as Issues and Pull Requests.

Adding the Action to Your Workflow

See the default action step definition:

- name: Generate Living Documentation
  id: generate_living_doc
  uses: AbsaOSS/[email protected]
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  
  with:
    repositories: '[
      {
        "orgName": "fin-services",
        "repoName": "investment-app",
        "queryLabels": ["feature", "enhancement"]
      },
      {
        "orgName": "health-analytics",
        "repoName": "patient-data-analysis",
        "queryLabels": ["functionality"]
      },
      {
        "orgName": "open-source-initiative",
        "repoName": "community-driven-project",
        "queryLabels": ["improvement"]
      }
    ]'

See the full example of action step definition (in example are used non-default values):

- name: Generate Living Documentation
  id: generate_living_doc
  uses: AbsaOSS/[email protected]
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  
  with:
    # features de/activation
    project-state-mining: true
    
    # features configuration
    projects-title-filter": ["Community Outreach Initiatives", "Health Data Analysis"]
    
    # page generator options
    milestones-as-chapters: true

    # inputs
    repositories: '[
      {
        "orgName": "fin-services",
        "repoName": "investment-app",
        "queryLabels": ["feature", "enhancement"]
      },
      {
        "orgName": "health-analytics",
        "repoName": "patient-data-analysis",
        "queryLabels": ["functionality"]
      },
      {
        "orgName": "open-source-initiative",
        "repoName": "community-driven-project",
        "queryLabels": ["improvement"]
      }
    ]'

Action Configuration

Configure the action by customizing the following parameters based on your needs:

Environment Variables

  • GITHUB_TOKEN (required):
    • Description: Your GitHub token for authentication.
    • Usage: Store it as a secret and reference it in the workflow file using ${{ secrets.GITHUB_TOKEN }}.
    • Example:
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Inputs

  • repositories (required)
    • Description: A JSON string defining the repositories to be included in the documentation generation.
    • Usage: List each repository with its organization name, repository name, and query labels.
    • Example:
      with:
        repositories: '[
          {
            "orgName": "fin-services",
            "repoName": "investment-app",
            "queryLabels": ["feature", "enhancement"]
          },
          {
            "orgName": "health-analytics",
            "repoName": "patient-data-analysis",
            "queryLabels": ["functionality"]
          },
          {
            "orgName": "open-source-initiative",
            "repoName": "community-driven-project",
            "queryLabels": ["improvement"]
          }
        ]'

Features de/activation

  • project-state-mining (optional, default: true)
    • Description: Enables or disables the mining of project state data from GitHub Projects.
    • Usage: Set to false to deactivate.
    • Example:
      with:
        project-state-mining: false

Features configuration

  • projects-title-filter (optional, default: [])
    • Description: Filters the projects by titles. Only projects with these titles will be considered.
    • Usage: Provide a list of project titles to filter.
    • Example:
      with:
        projects-title-filter: ["Community Outreach Initiatives", "Health Data Analysis"]

Page generator options

  • milestones-as-chapters (optional, default: false)
    • Description: When set to true, milestones in the projects will be treated as chapters in the generated documentation.
    • Usage: Set to true to enable this feature.
    • Example:
      with:
        milestones-as-chapters: true

Action Outputs

The Living Documentation Generator action provides a key output that allows users to locate and access the generated documentation easily. This output can be utilized in various ways within your CI/CD pipeline to ensure the documentation is effectively distributed and accessible.

  • documentation-path
    • Description: This output provides the path to the directory where the generated living documentation files are stored.
    • Usage:
     - name: Generate Living Documentation
       id: generate_doc
       ... rest of the action definition ...
       
     - name: Output Documentation Path
       run: echo "Generated documentation path: ${{ steps.generate_doc.outputs.documentation-path }}"            

Project Setup

If you need to build the action locally, follow these steps:

Prepare the Environment

node --version
python3 --version

Install Node.js Dependencies

npm install

Compile or Prepare the JavaScript Files

npm run build

Set Up Python Environment

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Run scripts locally

If you need to run the scripts locally, follow these steps:

Create the shell script

Create the shell file in the root directory. We will use run_script.sh.

touch run_script.sh

Add the shebang line at the top of the sh script file.

#!/bin/sh

Set the environment variables

Set the configuration environment variables in the shell script following the structure below. Also make sure that the GITHUB_TOKEN is configured in your environment variables.

export GITHUB_TOKEN=$(printenv GITHUB_TOKEN)
export PROJECT_STATE_MINING="true"
export PROJECTS_TITLE_FILTER="[]"
export MILESTONES_AS_CHAPTERS="true"
export REPOSITORIES='[
            {
              "orgName": "OrgName",
              "repoName": "example-project",
              "queryLabels": ["feature", "bug"]
            }
          ]'

Running the GH action locally

For running the whole GitHub action, add the following commands to the shell script:

cd src || exit 1

python3 controller.py --github-token "$GITHUB_TOKEN" \
            --project-state-mining "$PROJECT_STATE_MINING" \
            --projects-title-filter "$PROJECTS_TITLE_FILTER" \
            --milestones-as-chapters "$MILESTONES_AS_CHAPTERS" \
            --repositories "$REPOSITORIES"

cd .. || exit 1

Running single script locally

For running just one script at the time, add the following commands to the shell script:

cd src || exit 1

python3 github_query_project_state.py

cd .. || exit 1

Make the Script Executable

From the terminal that is in the root of this project, make the script executable:

chmod +x run_script.sh

Run the Script

./run_script.sh

Run unit test

TODO - check this chapter and update by latest state

Launch unit tests

pytest

To run specific tests or get verbose output:

pytest -v  # Verbose mode
pytest path/to/test_file.py  # Run specific test file

To check Test Coverage:

pytest --cov=../scripts

After running the tests

deactivate

Commit Changes

After testing and ensuring that everything is functioning as expected, prepare your files for deployment:

git add action.yml dist/index.js  # Adjust paths as needed
git commit -m "Prepare GitHub Action for deployment"
git push

Deployment

This project uses GitHub Actions for deployment draft creation. The deployment process is semi-automated by a workflow defined in .github/workflows/release_draft.yml.

  • Trigger the workflow: The release_draft.yml workflow is triggered on workflow_dispatch.
  • Create a new draft release: The workflow creates a new draft release in the repository.
  • Finalize the release draft: Edit the draft release to add a title, description, and any other necessary details related to GitHub Action.
  • Publish the release: Once the draft is ready, publish the release to make it available to the public.

Features

Data Mining from GitHub Repositories

This feature allows you to define which repositories should be included in the living documentation process. By specifying repositories, you can focus on the most relevant projects for your documentation needs.

  • Default Behavior: By default, the action will include all repositories defined in the repositories input parameter. Each repository is defined with its organization name, repository name, and query labels.

Data Mining from GitHub Projects

This feature allows you to define which projects should be included in the living documentation process. By specifying projects, you can focus on the most relevant projects for your documentation needs.

  • Default Behavior: By default, the action will include all projects defined in the repositories. This information is provided by the GitHub API.
  • Non-default Example: Use available options to customize which projects are included in the documentation.
    • project-state-mining: false deactivates the mining of project state data from GitHub Projects. If set to false, project state data will not be included in the generated documentation and project related configuration options will be ignored.
    • projects-title-filter: ["Community Outreach Initiatives", "Health Data Analysis"] filters the projects by titles, including only projects with these titles.

Living Documentation Page Generation

The goal is to provide a straightforward view of all issues in a single table, making it easy to see the overall status and details of issues across repositories.

  • Default Behavior: By default, the action generates a single table that lists all issues from the defined repositories.
  • Non-default Example: Use available options to customize the output, such as grouping issues by milestone.
    • milestones-as-chapters: true controls whether milestones are treated as chapters in the generated documentation.

Contribution Guidelines

We welcome contributions to the Living Documentation Generator! Whether you're fixing bugs, improving documentation, or proposing new features, your help is appreciated.

How to Contribute

Before contributing, please review our contribution guidelines for more detailed information.

License Information

This project is licensed under the Apache License 2.0. It is a liberal license that allows you great freedom in using, modifying, and distributing this software, while also providing an express grant of patent rights from contributors to users.

For more details, see the LICENSE file in the repository.

Contact or Support Information

If you need help with using or contributing to Living Documentation Generator Action, or if you have any questions or feedback, don't hesitate to reach out:

living-doc-generator's People

Contributors

miroslavpojer avatar mobitikula avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

living-doc-generator's Issues

Refactoring - OOP: Data containers

  • extract / change known data structures to specific custom data containers
  • possible for Dict[str, List[str]] in return type for convert_field_options_to_dict
  • example:
from dataclasses import dataclass

@dataclass
class Repository:
    orgName: str
    repoName: str
    queryLabels: List[str]

Refactoring - Scripts bug fixes

  • refactor send_graphql_query method as it is described in #4 (comment)

  • Be careful on these things:

output_file_path = f"{output_directory}/{output_file_name}"

it makes your code less multiplatform - this can't run on Windows because of different path delimiters. Better is to use

os.path.join function
  • Be careful about variable scopes. For example, in github_query_project_state.py, session = requests.Session() - the session is not passed to any function below that code, but it's used within function send_graphql_query directly.

Refactoring - Break complex methods

def main():
    data = "My data read from the Web"
    print(data)

if __name__ == "__main__":
    main()

Introduce Tests mining

Goal

  • Start scanning a test code to mine the test headers.
  • Introduce changes to requirements
    • Add a new chapter to the detail page for an overview of tests covering the feature.
      • link to the test, % coverage of the requirement
    • Add a new row to an initial details table - Total % of Requirement coverage by tests
  • Introduce changes to features
    • Add new columns providing test coverage by tests to all tables

Tasks

Action PoC RLS

The first goal is to release the PoC solution.

Tasks

  1. MobiTikula
  2. refactoring
    MobiTikula
  3. refactoring
    MobiTikula

Notes:

  • GH Token scope: Observed failures when trying to data mine data out of token scope. Unrelated repos from absa-group. This was not detected in the origin repository.
  • GH limit rate: Observed random data mining failures/instabilities during initial action development.

Refactoring - Project structure

Refactoring - Documentation and formatting

Introduce Requirements mining

Goal

  • Start mining for Requirements issues.
  • Start generating similar index and details pages for them as it is done for features issues.
  • Introduce changes to features
    • Rule 1: Each Requirement has one parent Feature.
    • Changes for Feature detail
      • A new chapter with a table of related requirements (with links to them, states, etc.)
    • Changes for Feature index overview
      • New columns in Feature tables: count of Requirements, % of finished (Done, Closed Requirements)

Tasks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.