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

Documentation #43

Open
1 of 2 tasks
johnnychen94 opened this issue Dec 8, 2020 · 6 comments
Open
1 of 2 tasks

Documentation #43

johnnychen94 opened this issue Dec 8, 2020 · 6 comments

Comments

@johnnychen94
Copy link
Member

johnnychen94 commented Dec 8, 2020

#36 #42 have brought up the documentation for this repo, which is awesome.

We still have something that needs to do to improve its usability:

  • hide the solutions by default
  • category-based and/or difficulty-based filters to better organize the documentation. This requires our problems indices shown on a new page, instead of on the sidebar. Hence a new democard theme is required here. (mid/long-term)
@rfhklwt
Copy link
Collaborator

rfhklwt commented Dec 8, 2020

我试验了一下:

  • 通过在docs/build/assets/themes下的两个css文件的末尾加上如下语句:
.none {
  color: transparent;
  text-shadow: 3px 3px 15px rgba(0, 0, 0, 1);
}.none .hljs-comment,
.none .hljs-built_in,
.none .hljs-meta,
.none .hljs-keyword,
.none .hljs-comment,
.none .hljs-string,
.none .hljs-literal,.none .hljs-number {  color: transparent;}
  • 接着在docs/build/assets里的documenter.js的末尾添加鼠标动作代码,如下:
let code = document.getElementsByClassName('language-julia')[0];
code.classList.add('none');
code.addEventListener('mouseover', function () {
  code.classList.remove('none');
});
code.addEventListener('mouseout', function () {
  code.classList.add('none');
});

就可以实现代码隐藏了,当鼠标没在代码框的时候,是这样的:
image
当鼠标移到代码框的时候,就会显示代码:
image

问题:

  • 一开始我打算在make.jl里对渲染文档生成的css文件和documenter.jl文件进行代码的补充的,将代码放置在makedocs之后,这个应该是没啥问题的把。github的临时文件的销毁应该是在这之后把?
    image
  • 照着这个思路然后发现在写入css时失败了,documenter.js成功。这是由于css在生成的时候是以只读文件的形式,所以无法写入。
  • 因此,可能需要你那边把css手动添加一下代码?或者去掉只读之类的,上面css代码是一个新样式,用于使字符模糊化的样式,因此不会影响到其他的。 @johnnychen94

@johnnychen94
Copy link
Member Author

Documenter.HTML 有接口可以使用。

单独保持为 leetcode.cssleetcode.js, 然后

format = Documenter.HTML(
    prettyurls=get(ENV, "CI", nothing) == "true"),
    assets = ["leetcode.css", "leetcode.js"]
)

试试看。

@rfhklwt
Copy link
Collaborator

rfhklwt commented Dec 8, 2020

Documenter.HTML 有接口可以使用。

单独保持为 leetcode.cssleetcode.js, 然后

format = Documenter.HTML(
    prettyurls=get(ENV, "CI", nothing) == "true"),
    assets = ["leetcode.css", "leetcode.js"]
)

试试看。

image
没有报错,但在build文件夹里面 没有看到这两个文件

@johnnychen94
Copy link
Member Author

johnnychen94 commented Dec 8, 2020

我这里是这样做的,也是路径需要调整一下 (我根据 Documenter.HTML 的文档改的)

# 1. generate demo files
demopage, postprocess_cb = makedemos("problems")
cp("docs/leetcode.css", "docs/src/democards/problems/leetcode.css")
cp("docs/leetcode.js", "docs/src/democards/problems/leetcode.js")


# 2. normal Documenter usage
format = Documenter.HTML(prettyurls=get(ENV, "CI", nothing) == "true",
    assets = ["democards/problems/leetcode.css", "democards/problems/leetcode.js"])

makedocs(format = format,
         pages = [
            "Home" => "index.md",
            demopage,
         ],
         sitename = "LeetCode")

然后在生成的每一个 html 文件里都能找到 leetcode.cssleetcode.js,但是我似乎看不到这个效果...

@rfhklwt
Copy link
Collaborator

rfhklwt commented Dec 8, 2020

makedocs(format = format,
         pages = [
            "Home" => "index.md",
            demopage,
         ],
         sitename = "LeetCode")

我试试看~

@rfhklwt
Copy link
Collaborator

rfhklwt commented Dec 8, 2020

试了一下,确实不行,只能是在theme里面的cssdocumentor.js更改的情况才有效。可能跟链接有关系。我明天再探索探索 @johnnychen94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants