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

Implemented automated doc generation with read the docs, Added a parser #23

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
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)
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
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
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)
21 changes: 21 additions & 0 deletions docs/gh_explainer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
gh\_explainer package
=====================

Submodules
----------

gh\_explainer.summarize module
------------------------------

.. automodule:: gh_explainer.summarize
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: gh_explainer
:members:
:undoc-members:
:show-inheritance:
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=source
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
7 changes: 7 additions & 0 deletions docs/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
project_explainer
=================

.. toctree::
:maxdepth: 4

gh_explainer
31 changes: 31 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
import os
import sys
sys.path.insert(0, os.path.abspath('/Users/ethanhunt/Desktop/Project-Explainer'))

project = 'PROJECT-EXPLAINER'
copyright = '2024, C2SI'
author = 'C2SI'
release = '27 Aug, 2023'

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

extensions = []

templates_path = ['_templates']
exclude_patterns = []

language = 'Python, Jupyter Notebook'

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

html_theme = 'alabaster'
html_static_path = ['_static']
21 changes: 21 additions & 0 deletions docs/source/gh_explainer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
gh\_explainer package
=====================

Submodules
----------

gh\_explainer.summarize module
------------------------------

.. automodule:: gh_explainer.summarize
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: gh_explainer
:members:
:undoc-members:
:show-inheritance:
20 changes: 20 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. PROJECT-EXPLAINER documentation master file, created by
sphinx-quickstart on Fri Mar 8 17:31:18 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to PROJECT-EXPLAINER's documentation!
=============================================

.. toctree::
:maxdepth: 2
:caption: Contents:



Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
7 changes: 7 additions & 0 deletions docs/source/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
project_explainer
=================

.. toctree::
:maxdepth: 4

gh_explainer
35 changes: 35 additions & 0 deletions 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=source
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
1 change: 1 addition & 0 deletions project_explainer/examples/Project-Explainer
Submodule Project-Explainer added at 3af021
39 changes: 39 additions & 0 deletions project_explainer/github_parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from github import Github
import os

# Initialize a Github instance with an access token
g = Github(os.getenv('GITHUB_TOKEN'))

def get_repo_info(repo_name):
repo = g.get_repo(repo_name)

# Fetching repository metadata
stars = repo.stargazers_count
forks = repo.forks_count
contributors = repo.get_contributors().totalCount

print(f"Stars: {stars}, Forks: {forks}, Contributors: {contributors}")

def parse_issues(repo_name):
repo = g.get_repo(repo_name)
issues = repo.get_issues(state='open')

print("\nOpen Issues:")
for issue in issues:
print(f"- {issue.title}: {issue.html_url}")

def parse_pull_requests(repo_name):
repo = g.get_repo(repo_name)
pull_requests = repo.get_pulls(state='open', sort='created')

print("\nOpen Pull Requests:")
for pr in pull_requests:
print(f"- {pr.title}: {pr.html_url}")

if __name__ == "__main__":
repo_name = "c2siorg/Project-Explainer"

print(f"Fetching information for {repo_name}")
get_repo_info(repo_name)
parse_issues(repo_name)
parse_pull_requests(repo_name)
3 changes: 3 additions & 0 deletions project_explainer/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
gradio
-e git+https://github.com/c2siorg/Project-Explainer.git@main#subdirectory=project_explainer&egg=gh_explainer&egg=gh_explainer
-e git+https://github.com/c2siorg/Project-Explainer.git@main#subdirectory=project_processor&egg=gh_processor
1 change: 1 addition & 0 deletions project_explainer/src/gh-explainer
Submodule gh-explainer added at 3af021
1 change: 1 addition & 0 deletions project_explainer/src/gh-processor
Submodule gh-processor added at 3af021
1 change: 1 addition & 0 deletions project_explainer_ui/core-js
Submodule core-js added at c3fc79
7 changes: 7 additions & 0 deletions project_explainer_ui/readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
sphinx:
configuration: docs/conf.py
python:
version: 3.10
install:
- requirements: project_explainer_ui/requirements.txt
1 change: 1 addition & 0 deletions project_explainer_ui/src/gh-explainer
Submodule gh-explainer added at 3af021
1 change: 1 addition & 0 deletions project_explainer_ui/src/gh-processor
Submodule gh-processor added at 3af021
15 changes: 11 additions & 4 deletions project_explainer_ui/ui.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import gradio as gr
from gh_explainer import Explainer



def summarize(summarization_type, github_project_url, github_project_branch="main", huggingface_model_id="gpt2"):
gptExplainer = Explainer(huggingface_model_id)
if summarization_type == "brief":
return gptExplainer.brief(github_url=github_project_url, branch=github_project_branch)["summary"]
return gptExplainer.outline(github_url=github_project_url, branch=github_project_branch)["summary"]
try:
gptExplainer = Explainer(huggingface_model_id)
if summarization_type == "brief":
return gptExplainer.brief(github_url=github_project_url, branch=github_project_branch)["summary"]
return gptExplainer.outline(github_url=github_project_url, branch=github_project_branch)["summary"]
except Exception as e:
return f"An error occurred: {str(e)}"



demo = gr.Interface(
fn=summarize,
Expand Down
9 changes: 9 additions & 0 deletions readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2

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

sphinx:
configuration: docs/source/conf.py
28 changes: 28 additions & 0 deletions source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'PROJECT-EXPLAINER'
copyright = '2024, C2SI'
author = 'C2SI'
release = '27 Aug, 2023'

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

extensions = []

templates_path = ['_templates']
exclude_patterns = []

language = 'Python, Jupyter Notbook'

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

html_theme = 'alabaster'
html_static_path = ['_static']
20 changes: 20 additions & 0 deletions source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. PROJECT-EXPLAINER documentation master file, created by
sphinx-quickstart on Fri Mar 8 18:39:47 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.

Welcome to PROJECT-EXPLAINER's documentation!
=============================================

.. toctree::
:maxdepth: 2
:caption: Contents:



Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
1 change: 1 addition & 0 deletions src/gh-explainer
Submodule gh-explainer added at 3af021
1 change: 1 addition & 0 deletions src/gh-processor
Submodule gh-processor added at 3af021