diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml
index 12b4f201..d1633abf 100644
--- a/.github/workflows/python-app.yml
+++ b/.github/workflows/python-app.yml
@@ -11,7 +11,7 @@ on:
jobs:
lint:
- runs-on: ubuntu-latest
+ runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
@@ -31,7 +31,7 @@ jobs:
run: poetry run pylint src
build:
- runs-on: ubuntu-latest
+ runs-on: ubuntu-18.04
needs: lint
steps:
@@ -52,14 +52,14 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: gen
- - name: Copy to website
- uses: andstor/copycat-action@v3
- with:
- personal_token: ${{ secrets.CI_PAT }}
- src_path: /.
- src_branch: gh-pages
- dst_path: /docs/reference/.
- dst_branch: gh-pages
- dst_owner: enso-org
- dst_repo_name: website
- clean: true
+# - name: Copy to website
+# uses: andstor/copycat-action@v3
+# with:
+# personal_token: ${{ secrets.CI_PAT }}
+# src_path: /.
+# src_branch: gh-pages
+# dst_path: /docs/reference/.
+# dst_branch: gh-pages
+# dst_owner: enso-org
+# dst_repo_name: website
+# clean: true
diff --git a/.gitignore b/.gitignore
index 9bc836a1..9c858efa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,6 +41,7 @@ Thumbs.db
.vscode/
distribution/
gen/
+temp/
.idea
venv
__pycache__
\ No newline at end of file
diff --git a/.pylintrc b/.pylintrc
index 629f1bc5..64734a0c 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -564,7 +564,7 @@ max-bool-expr=5
max-branches=12
# Maximum number of locals for function / method body.
-max-locals=15
+max-locals=20
# Maximum number of parents for a class (see R0901).
max-parents=7
diff --git a/src/constants.py b/src/constants.py
index a3c0b9a0..3175f784 100644
--- a/src/constants.py
+++ b/src/constants.py
@@ -15,7 +15,7 @@
DIRECTORY: str = "distribution/std-lib"
#: The commit from which scala parser will be obtained.
-PARSER_COMMIT: str = "43c6fde4ef5873c645aa1ff196d7b36864831468"
+PARSER_COMMIT: str = "9ea38e66db60953f9955ca9ee60c9c4478ff251f"
#: The URL used to download scala parser package.
PARSER_URL: str = "https://packages.luna-lang.org/parser-js/nightly/"
#: The method in scala parser used to generate documentation from AST.
@@ -25,7 +25,7 @@
#: The URL leading to IDE repository.
IDE_REPO_URL: str = "https://raw.githubusercontent.com/enso-org/ide/"
#: The branch in the above repository from which stylesheet will be downloaded.
-IDE_BRANCH: str = "develop"
+IDE_BRANCH: str = "wip/mm/doc-stylesheet"
#: The directory in the above repository from which stylesheet will be obtained.
IDE_DIRECTORY: str = "/src/rust/ide/view/src/documentation/"
diff --git a/src/create_static.py b/src/create_static.py
index 3d8db258..591b1889 100644
--- a/src/create_static.py
+++ b/src/create_static.py
@@ -6,101 +6,94 @@
from airium import Airium
-def create_index_page(out_dir: str, out_name: str, gen_files: List[str]) -> None:
+def add_breadcrumbs_to_pages(out_dir: str, temp_dir: str, gen_files: List[str]) -> None:
"""
- Generates index page.
+ Method used to create breadcrumbs (for now - tree) and add them to generated content.
"""
template = Airium()
- logging.info("Generating: %s", out_name)
- with template.html():
- with template.head():
- template.title(_t="Enso Reference")
- template.link(href="style.css", rel="stylesheet")
- template.link(href="favicon.ico", rel="icon")
- template.style(_t="ul { padding-inline-start: 15px; }")
- template.style(
- _t="""ul, .section ul {
- list-style: none;
- padding: 0;
- margin: 0;
- word-wrap: initial;
- }
-
- ul li {
- padding: 5px 10px;
- }
-
- .section ul { display: none; }
- .section input:checked ~ ul { display: block; }
- .section input[type=checkbox] { display: none; }
- .section {
- position: relative;
- padding-left: 20px !important;
- }
-
- .section label:after {
- content: "+";
- position: absolute;
- top: 0; left: 0;
- padding: 0;
- text-align: center;
- font-size: 17px;
- color: cornflowerblue;
- transition: all 0.3s;
- }
-
- .section input:checked ~ label:after {
- color: cadetblue;
- transform: rotate(45deg);
- }
-
- @media only screen and (max-width: 1100px) {
- #tree {
- width: 30% !important;
- }
- }
- """
- )
- template.script(
- _t="""function set_frame_content(file) {
- document.getElementById("frame").src = file
- }"""
- )
- with template.body(style="background-color: #333"):
- template.h2(
- style="""text-align: center;
- padding: 15px;
- margin: 0;
- color: #fafafa""",
- _t="Enso Reference",
- )
- with template.div(
- style="background-color: #fafafa; display: flex; height: 100%"
- ):
- with template.div(
- id="tree",
- style="""background-color: #efefef;
- border-radius: 14px;
- width: 20%;
- margin: 15px;
- padding-left: 20px;
- overflow: scroll;
- height: 90%;""",
- ):
- grouped_file_names = group_by_prefix(gen_files)
- create_html_tree(template, "", grouped_file_names, gen_files)
- template.iframe(
- frameborder="0",
- height="100%",
- id="frame",
- src="Base-Main.html",
- width="100%",
- target="_blank",
- )
+ logging.info("Generating breadcrumbs")
+ gen_files.remove("Main")
+ grouped_file_names = group_by_prefix(gen_files)
+ create_html_tree(template, "", grouped_file_names, gen_files)
+ breadcrumbs = str(template).replace('class="', 'className="')
- html_file = open(out_dir + "/" + out_name, "w")
- html_file.write(str(template))
- html_file.close()
+ stl = """
+
+ """
+
+ breadcrumbs = "
" + stl + breadcrumbs + "
"
+
+ for out_name in gen_files:
+ temp_file = open(temp_dir + "/" + out_name + ".js", "r")
+ out_file = open(out_dir + "/" + out_name + ".js", "w")
+ temp_br = breadcrumbs
+ partials = out_name.split("-")
+ valid_ids = ["-".join(partials[:i]) for i in range(len(partials))]
+ for elem in valid_ids:
+ beg = '", beg + 'checked="True" />')
+ beg_link = 'href="' + out_name + '"'
+ temp_br = temp_br.replace(beg_link, beg_link + ' className="font-bold"')
+ out_file.write(temp_file.read().replace("{/*BREADCRUMBS*/}", temp_br))
+ temp_file.close()
+ out_file.close()
+
+ std_main_file = open(temp_dir + "/" + "Base-Data-Maybe.js", "r")
+ index_file = open(out_dir + "/" + "index.js", "w")
+ index_file.write(
+ std_main_file.read().replace(
+ "{/*BREADCRUMBS*/}", breadcrumbs.replace('a href="', 'a href="reference/')
+ )
+ )
+ std_main_file.close()
+ index_file.close()
def create_html_tree(
@@ -112,15 +105,18 @@ def create_html_tree(
if len(ele) > 0:
with template.ul():
for key, value in ele.items():
- file_name = curr_beg + "-" + key
+ file_name = curr_beg + "-" + key if len(curr_beg) > 0 else key
action = ""
if file_name in all_existing_files:
- action = "set_frame_content('" + file_name + ".html')"
+ action = file_name
+ elif file_name + "-Main" in all_existing_files:
+ action = file_name + "-Main"
if len(value) > 0:
klass = "section"
with template.li(klass=klass):
template.input(type="checkbox", id=file_name)
- template.label(for_=file_name, _t=key, onclick=action)
+ with template.label(for_=file_name):
+ template.a(href=action, _t=key)
beg = curr_beg
if len(curr_beg) == 0:
beg = key
@@ -128,7 +124,8 @@ def create_html_tree(
beg = beg + "-" + key
create_html_tree(template, beg, value, all_existing_files)
else:
- template.li(onclick=action, _t=key)
+ with template.li():
+ template.a(href=action, _t=key)
def group_by_prefix(strings: List[str]) -> dict:
diff --git a/src/main.py b/src/main.py
index 6fb0d4a8..a1747ce3 100644
--- a/src/main.py
+++ b/src/main.py
@@ -4,9 +4,10 @@
import argparse
import logging
import constants
-from downloaders import download_stdlib, download_parser, download_stylesheet
-from parse import init_parser, init_gen_dir, gen_all_files
-from create_static import create_index_page
+from downloaders import download_stdlib, download_parser
+from safe_create_directory import safe_create_directory
+from parse import init_parser, gen_all_files
+from create_static import add_breadcrumbs_to_pages
def main(arguments: argparse.Namespace) -> None:
@@ -14,15 +15,16 @@ def main(arguments: argparse.Namespace) -> None:
Program entry point.
"""
logging.basicConfig(level=arguments.log_level)
- download_stdlib(
- arguments.token, arguments.org, arguments.repo, arguments.br, arguments.dir
- )
- download_parser(arguments.parser_url, arguments.commit, arguments.parser)
- download_stylesheet(arguments.ide_br, arguments.style)
+ if not arguments.dont_download:
+ download_stdlib(
+ arguments.token, arguments.org, arguments.repo, arguments.br, arguments.dir
+ )
+ download_parser(arguments.parser_url, arguments.commit, arguments.parser)
parser = init_parser(arguments.parser)
- init_gen_dir(arguments.out, arguments.style)
- gen_files = gen_all_files(parser, arguments.std, arguments.out, arguments.style)
- create_index_page(arguments.out, arguments.index, gen_files)
+ safe_create_directory("temp")
+ safe_create_directory(arguments.out)
+ gen_files = gen_all_files(parser, arguments.std, "temp")
+ add_breadcrumbs_to_pages(arguments.out, "temp", gen_files)
logging.info("All done.")
@@ -66,5 +68,8 @@ def main(arguments: argparse.Namespace) -> None:
"--index", default=constants.INDEX_FILE, help="Index page name."
)
arg_parser.add_argument("--log_level", default=logging.INFO, help="Logging level.")
+ arg_parser.add_argument(
+ "--dont_download", default=False, help="Have local stdlib and parser."
+ )
args = arg_parser.parse_args()
main(args)
diff --git a/src/parse.py b/src/parse.py
index 03fa4258..dcbf64c0 100644
--- a/src/parse.py
+++ b/src/parse.py
@@ -6,12 +6,10 @@
from typing import List
import execjs
import constants
-from copy_file import copy_file
-from safe_create_directory import safe_create_directory
def gen_all_files(
- parser: execjs.ExternalRuntime, std_dir: str, out_dir: str, style_file: str
+ parser: execjs.ExternalRuntime, std_dir: str, out_dir: str
) -> List[str]:
"""
Recursively generates all doc files and puts them into the `gen` directory.
@@ -23,12 +21,13 @@ def gen_all_files(
filename.replace(std_dir + "/", "")
.replace("/", "-")
.replace("-src-", "-")
- .replace(constants.FILE_EXT, ".html")
+ .replace("Standard-", "")
+ .replace(constants.FILE_EXT, ".js")
)
logging.info("Generating: %s", out_file_name)
try:
- __gen_file(parser, filename, out_file_name, out_dir, style_file)
- all_file_names.append(out_file_name.replace(".html", ""))
+ __gen_file(parser, filename, out_file_name, out_dir)
+ all_file_names.append(out_file_name.replace(".js", ""))
except execjs.Error as err:
logging.info("Could not generate: %s", out_file_name)
logging.info("Got an exception: %s", str(err))
@@ -37,18 +36,13 @@ def gen_all_files(
def __gen_file(
- parser: execjs.ExternalRuntime,
- path: str,
- out_name: str,
- out_dir: str,
- style_file: str,
+ parser: execjs.ExternalRuntime, path: str, out_name: str, out_dir: str
) -> None:
"""
Generates an HTML file from Enso source file provided with `path` and saves
it as `out_name`.
"""
enso_file = open(path, "r")
- stylesheet_link = ''
parsed = parser.call(constants.PARSE_AST_METHOD, enso_file.read())
enso_file.close()
html_file = open(out_dir + "/" + out_name, "w")
@@ -57,21 +51,18 @@ def __gen_file(
constants.PARSE_PURE_METHOD,
"\n\n*Enso Reference Viewer.*\n\nNo documentation available for chosen source file.",
)
- html_file.write(stylesheet_link + parsed.replace("display: flex", "display: none"))
+ html_file.write(
+ read_template("template.js").replace(
+ "{/*PAGE*/}",
+ parsed.replace("display: flex", "display: none")
+ .replace("
", "
")
+ .replace("{", "{")
+ .replace("}", "}"),
+ )
+ )
html_file.close()
-def init_gen_dir(name: str, style_file: str) -> None:
- """
- Creates the `gen` directory with all necessary files.
- """
- safe_create_directory(name)
- stylesheet_file: str = "/" + style_file
- favicon_file: str = "favicon.ico"
- copy_file(constants.IN_DIR + stylesheet_file, name + stylesheet_file)
- copy_file(favicon_file, name + "/" + favicon_file)
-
-
def init_parser(parser_file: str) -> execjs.ExternalRuntime:
"""
Compiles the JS parser to call from within Python code.
@@ -79,3 +70,11 @@ def init_parser(parser_file: str) -> execjs.ExternalRuntime:
parser = open(constants.IN_DIR + "/" + parser_file, "r").read()
parser = execjs.compile(parser)
return parser
+
+
+def read_template(template_file: str) -> str:
+ """
+ Reads the template into a string.
+ """
+ template = open("src/" + template_file, "r").read()
+ return template
diff --git a/src/template.js b/src/template.js
new file mode 100644
index 00000000..6f55287e
--- /dev/null
+++ b/src/template.js
@@ -0,0 +1,57 @@
+import { StaticNavigation } from "components/navigation";
+import {
+ Container,
+ ContainerOrScreenIfSmall,
+ RootContainer,
+} from "components/container";
+import { Header } from "components/header";
+import { Chapter } from "components/chapter";
+import { SectionCommunity } from "components/section-community";
+import { SectionFooter } from "components/section-footer";
+import { StickyButtons } from "components/sticky-buttons";
+
+import AtomsIcon from "../../../public/img/icon/atoms.svg";
+import MethodsIcon from "../../../public/img/icon/methods.svg";
+import SubmodulesIcon from "../../../public/img/icon/submodules.svg";
+
+function Docs() {
+ return (
+
+ {/*
*/}
+ {/* /!*BREADCRUMBS2*!/*/}
+ {/*
*/}
+
+
+
{/*BREADCRUMBS*/}
+ {/*PAGE*/}
+
+
+
+ );
+}
+
+export default function Main(props) {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}