forked from OpenBB-finance/OpenBB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation extension to Jupyter Lab (OpenBB-finance#745)
* Add documentation extension to Jupyter Lab * Fix lint * fix pyupgrade * Change label from Documentation to Gamestonk Documentation * Improve code after review
- Loading branch information
1 parent
bb17974
commit 6a2792e
Showing
23 changed files
with
450 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
dist | ||
coverage | ||
**/*.d.ts | ||
ui-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
module.exports = { | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/eslint-recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:jsdoc/recommended', | ||
'plugin:prettier/recommended', | ||
'plugin:react/recommended', | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
project: 'tsconfig.json', | ||
sourceType: 'module', | ||
}, | ||
plugins: ['@typescript-eslint', 'jsdoc'], | ||
rules: { | ||
'@typescript-eslint/naming-convention': [ | ||
'error', | ||
{ | ||
selector: 'interface', | ||
format: ['PascalCase'], | ||
custom: { | ||
regex: '^I[A-Z]', | ||
match: true, | ||
}, | ||
}, | ||
], | ||
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-namespace': 'off', | ||
'@typescript-eslint/no-use-before-define': 'off', | ||
'@typescript-eslint/quotes': [ | ||
'error', | ||
'single', | ||
{ avoidEscape: true, allowTemplateLiterals: false }, | ||
], | ||
curly: ['error', 'all'], | ||
eqeqeq: 'error', | ||
'jsdoc/require-param-type': 'off', | ||
'jsdoc/require-property-type': 'off', | ||
'jsdoc/require-returns-type': 'off', | ||
'jsdoc/no-types': 'warn', | ||
'prefer-arrow-callback': 'error', | ||
}, | ||
settings: { | ||
jsdoc: { | ||
mode: 'typescript', | ||
}, | ||
react: { | ||
version: 'detect', | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
include LICENSE | ||
include README.md | ||
include pyproject.toml | ||
include jupyter-config/gamestonk_terminal_documentation.json | ||
|
||
include package.json | ||
include ts*.json | ||
|
||
graft gamestonk_terminal_documentation/labextension | ||
|
||
# Javascript files | ||
graft src | ||
graft style | ||
prune **/node_modules | ||
prune lib | ||
|
||
# Patterns to exclude from any directory | ||
global-exclude *~ | ||
global-exclude *.pyc | ||
global-exclude *.pyo | ||
global-exclude .git | ||
global-exclude .ipynb_checkpoints |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Gamestonk Teminal Documentation | ||
|
||
This extensions adds a button into the Gamestonk Terminal category of the Jupyter Lab launcher panel. | ||
|
||
## Install, Use and Develop | ||
|
||
```bash | ||
pip install -e . | ||
jlpm | ||
jlpm run build:prod | ||
jupyter labextension install . | ||
|
||
# Rebuild Typescript source after making changes | ||
jlpm build | ||
# Rebuild JupyterLab after making any changes | ||
jupyter lab build | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Making a new release of gamestonk-settings | ||
|
||
Check out the [workflow documentation](https://github.com/jupyter-server/jupyter_releaser#typical-workflow) for information. |
13 changes: 13 additions & 0 deletions
13
jupyterlab/documentation/gamestonk_terminal_documentation/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import json | ||
import os.path as osp | ||
|
||
from ._version import __version__ # noqa: F401 | ||
|
||
HERE = osp.abspath(osp.dirname(__file__)) | ||
|
||
with open(osp.join(HERE, "labextension", "package.json")) as fid: | ||
data = json.load(fid) | ||
|
||
|
||
def _jupyter_labextension_paths(): | ||
return [{"src": "labextension", "dest": data["name"]}] |
2 changes: 2 additions & 0 deletions
2
jupyterlab/documentation/gamestonk_terminal_documentation/_version.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
version_info = (0, 1, 0) | ||
__version__ = ".".join(map(str, version_info)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"packageManager": "python", | ||
"packageName": "gamestonk_terminal_documentation", | ||
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package gamestonk_terminal_documentation" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
"name": "@gamestonk/documentation", | ||
"version": "0.1.0", | ||
"description": "Gamestonk terminal documentation", | ||
"keywords": [ | ||
"jupyter", | ||
"jupyterlab", | ||
"jupyterlab-extension" | ||
], | ||
"homepage": "https://github.com/GamestonkTerminal/GamestonkTerminal", | ||
"bugs": { | ||
"url": "https://github.com/GamestonkTerminal/GamestonkTerminal/issues" | ||
}, | ||
"license": "MIT", | ||
"author": { | ||
"name": "Project Jupyter Contributors", | ||
"email": "[email protected]" | ||
}, | ||
"files": [ | ||
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", | ||
"style/**/*.{css,eot,js,gif,html,jpg,json,png,svg,woff2,ttf}", | ||
"schema/**/*.json" | ||
], | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"style": "style/index.css", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/GamestonkTerminal/GamestonkTerminal.git" | ||
}, | ||
"scripts": { | ||
"build": "jlpm run build:lib && jlpm run build:labextension:dev", | ||
"build:all": "jlpm run build:lib && jlpm run build:labextension", | ||
"build:labextension": "jupyter labextension build .", | ||
"build:labextension:dev": "jupyter labextension build --development True .", | ||
"build:lib": "tsc", | ||
"build:prod": "jlpm run clean && jlpm run build:lib && jlpm run build:labextension", | ||
"clean": "jlpm run clean:lib", | ||
"clean:all": "jlpm run clean:lib && jlpm run clean:labextension", | ||
"clean:labextension": "rimraf gamestonk_terminal_documentation/labextension", | ||
"clean:lib": "rimraf lib tsconfig.tsbuildinfo", | ||
"eslint": "eslint . --ext .ts,.tsx --fix", | ||
"eslint:check": "eslint . --ext .ts,.tsx", | ||
"install:extension": "jlpm run build", | ||
"prepare": "jlpm run clean && jlpm run build:prod", | ||
"watch": "run-p watch:src watch:labextension", | ||
"watch:labextension": "jupyter labextension watch .", | ||
"watch:src": "tsc -w" | ||
}, | ||
"dependencies": { | ||
"@jupyterlab/application": "^3.1.0", | ||
"@jupyterlab/launcher": "^3.1.0", | ||
"@jupyterlab/mainmenu": "^3.1.7" | ||
}, | ||
"devDependencies": { | ||
"@jupyterlab/builder": "^3.1.0", | ||
"@typescript-eslint/eslint-plugin": "^4.8.1", | ||
"@typescript-eslint/parser": "^4.8.1", | ||
"eslint": "^7.14.0", | ||
"eslint-config-prettier": "^6.15.0", | ||
"eslint-plugin-jsdoc": "^36.0.0", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"eslint-plugin-react": "^7.18.3", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.1.1", | ||
"rimraf": "^3.0.2", | ||
"typescript": "~4.1.3" | ||
}, | ||
"sideEffects": [ | ||
"style/*.css", | ||
"style/*.svg", | ||
"style/index.js" | ||
], | ||
"jupyterlab": { | ||
"extension": true, | ||
"outputDir": "gamestonk_terminal_documentation/labextension", | ||
"schemaDir": "schema" | ||
}, | ||
"styleModule": "style/index.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[build-system] | ||
requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.1"] | ||
build-backend = "jupyter_packaging.build_api" | ||
|
||
[tool.jupyter-packaging.options] | ||
skip-if-exists = ["gamestonk_terminal_documentation/labextension/static/style.js"] | ||
ensured-targets = ["gamestonk_terminal_documentation/labextension/static/style.js", "gamestonk_terminal_documentation/labextension/package.json"] | ||
|
||
[tool.jupyter-packaging.builder] | ||
factory = "jupyter_packaging.npm_builder" | ||
|
||
[tool.jupyter-packaging.build-args] | ||
build_cmd = "build:prod" | ||
npm = ["jlpm"] | ||
|
||
[tool.check-manifest] | ||
ignore = ["gamestonk_terminal_documentation/labextension/**", "yarn.lock", ".*", "package-lock.json"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"title": "Gamestonk Terminal Documentation", | ||
"description": "Gamestonk Terminal Documentation.", | ||
"jupyter.lab.menus": { | ||
"main": [ | ||
{ | ||
"id": "jp-mainmenu-file", | ||
"items": [ | ||
{ | ||
"type": "submenu", | ||
"id": "jp-mainmenu-file-new", | ||
"items": [ | ||
{ | ||
"command": "gamestonk:documentation", | ||
"rank": 30 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"additionalProperties": false, | ||
"type": "object" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
""" | ||
gamestonk_terminal_documentation setup | ||
""" | ||
import json | ||
import sys | ||
from pathlib import Path | ||
|
||
import setuptools | ||
|
||
HERE = Path(__file__).parent.resolve() | ||
|
||
# The name of the project | ||
name = "gamestonk_terminal_documentation" | ||
|
||
lab_path = HERE / name.replace("-", "_") / "labextension" | ||
|
||
# Representative files that should exist after a successful build | ||
ensured_targets = [str(lab_path / "package.json"), str(lab_path / "static/style.js")] | ||
|
||
labext_name = "@gamestonk/documentation" | ||
|
||
data_files_spec = [ | ||
( | ||
"share/jupyter/labextensions/%s" % labext_name, | ||
str(lab_path.relative_to(HERE)), | ||
"**", | ||
), | ||
("share/jupyter/labextensions/%s" % labext_name, ".", "install.json"), | ||
] | ||
|
||
long_description = (HERE / "README.md").read_text() | ||
|
||
# Get the package info from package.json | ||
pkg_json = json.loads((HERE / "package.json").read_bytes()) | ||
|
||
setup_args = dict( | ||
name=name, | ||
version=pkg_json["version"], | ||
url=pkg_json["homepage"], | ||
author=pkg_json["author"]["name"], | ||
author_email=pkg_json["author"]["email"], | ||
description=pkg_json["description"], | ||
license=pkg_json["license"], | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
packages=setuptools.find_packages(), | ||
install_requires=[], | ||
zip_safe=False, | ||
include_package_data=True, | ||
python_requires=">=3.6", | ||
platforms="Linux, Mac OS X, Windows", | ||
keywords=["Jupyter", "JupyterLab", "JupyterLab3"], | ||
classifiers=[ | ||
"License :: OSI Approved :: BSD License", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.6", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Framework :: Jupyter", | ||
], | ||
) | ||
|
||
try: | ||
from jupyter_packaging import wrap_installers, npm_builder, get_data_files | ||
|
||
post_develop = npm_builder( | ||
build_cmd="install:extension", source_dir="src", build_dir=lab_path | ||
) | ||
setup_args["cmdclass"] = wrap_installers( | ||
post_develop=post_develop, ensured_targets=ensured_targets | ||
) | ||
setup_args["data_files"] = get_data_files(data_files_spec) | ||
except ImportError as e: | ||
import logging | ||
|
||
logging.basicConfig(format="%(levelname)s: %(message)s") | ||
logging.warning( | ||
"Build tool `jupyter-packaging` is missing. Install it with pip or conda." | ||
) | ||
if not ("--name" in sys.argv or "--version" in sys.argv): | ||
raise e | ||
|
||
if __name__ == "__main__": | ||
setuptools.setup(**setup_args) |
Oops, something went wrong.