Closed JordanMartinez closed 5 years ago
Purpose
Principles
Outcome 1
*.purs
or *.md
files so that everything else gets excluded by default (hidden files/folders (starts with "."), dependency manager files ("psc-package.json")).file-name.md#section-header
).file-name.purs#L4
).development
branch's ToC file will always be outdated. Likewise, the latestRelease
branch will be correct only for one release. When a new major release is made, previous releases would no longer refer to the correct pages if files' names or locations had changed, leading to broken links. Thus, the links should refer to a tag on GitHub rather than a branch name or a commit hash, so that each release always refers to itself as the version to use for finding files.The format of the ToC could appear in two different ways:
<details><summary> ... </details>
HTML tags
The format of the ToC should look like this:
An example using current project setup
...
Outcome 2
Brainwrite
Update on this project:
First, I've learned how to use yargs, node-path, node-fs-aff, and string-parsers
. The are still a few things with string-parsers
that I don't understand. Since I didn't need to use them AFAIK, I'm not going to cover them further. Also, I did not figure out how to produce great parsing errors, so sometimes it was difficult to track down a bug/issue in the parser code itself.
Second, I realized that the nested nature of these headers can get pretty complicated to parse when one includes multi-line comments. For example,
------------
-- These are not an issue...
-- ## 1 - This is a header
-- ### 1.1 - This is a header
-- ### 1.2 - This is a header
------------
-- These possibilities do present an issue
-- ## 2 - This is a header
{-
### 2.1 - This is a header
-}
{- ### 2.2 - This is a header -}
{-
#### 2.2.1 - This is a header
#### 2.2.2 - This is a header
-}
-- #### 2.2.3 - This is a header
Third, there are situations where I might include '#' in a comment as a reference to the 'applyFlipped' function name: arg # function
. I believe that occurs sometimes in a multi-line comment, so it makes it much harder to distinguish a header prefix from a regular function.
Thus, to keep things simple (though this could be improved in the future), headers in PS files will look like this:
-- ####... Header Text on regular single-line comment
{-
-- ####... Header Text inside a block-level / multi-line comment: make it look like a single-line comment
-}
{- -- ###... this is not a header -}
Another update on this:
The program works!
Things I've fixed since the last update:
Things I still have to do:
benchmark
folder appears before the src
and test
folders when it should appear afterwards if one wants to read this in a natural ordering. I might work on this by providing better sorting options before the content gets rendered or I might not because that only improves the result by a small factor.Other issues I found:
h1
for something and an h3
follows it rather than an h2
. The current version of the program will indent such items four spaces too much and the result will be understood as code, not a list item in a bulleted list.You can see the output in the temporary table-of-contents.md file (link below). Be aware of these things when using that link:
development
branch, not the latestRelease
branch. The temporary table-of-contents.md
file in the development branch.
Latest update:
Projects/src/Table of Contents/ToC/
Things left to do in this issue:
Latest update on this. I've refactored the code a bit in an attempt to verify that the file's URLs are valid. I encountered a 'Maximum Call Stack Size Exceeded' error, and it took some time to realize that the problem was caused by referring to the wrong variable.
However, there was some good news from this:
tailRec
and understand why/when one should use itgo
function as a different name when its used throughout a project as it makes tracking down any stack-size errors easier to find.Overall, I don't think I like the program logic of my current not-yet-pushed design. On one hand, I'm trying to make it fast. On the other hand, that desire might make the code much harder for a new learner to understand.
Latest update on this.
In my initial design of this program, I walked the file tree once to parse the content and I walked the resulting structure a second time to render it. After having a better understanding of the design space, I saw that that was largely wasteful in CPU cycles. In the current implementation (now pushed to the development
branch), I walk the file system once, parse and render files, and render directories as I return to its parent directory. The previous approach was more like OO in FP syntax whereas this second approach is more like the FP declarative programming style via traverse
. (I guess that's why they say that Traversable
is the answer to everything...)
On top of that, I made it run in parallel thanks to Parallel
and Aff
. (Actually, running it in parallel means my logger is now incorrect.... Ha! Whoops!)
I am also checking the file's URLs for a 200 HTTP code before I render them, so that if it fails, then I just render a plain text entry for that item in the resulting file. If it succeeds, I'll render it as a hyperlink using that file.
The code could still be cleaned up in a few ways:
API
folder might as well be removed and make the AppM
file take its place.Before making a new release, Travis CI should now run this program and fail if a single link is considered invalid
On top of that, there's a few other issues relating to new people reading this for the first time:
Rather than delaying a release, I'll just work on this more in separate issues.
Closed by #278
43 has the idea of a single file that acts like a clickable ToC that will open up the corresponding file, making navigation much easier overall.
I'd like to target this concept as the next in-repo project to work on. I think the libraries it should cover are:
Thus, I will write a program that generates outputs/updates a file with an up-to-date Table of Contents of this entire repo that, when an entry is clicked, will open the corresponding file in GitHub on the
latestRelease
branch.While it will produce a GitHub-friendly version by default, it should be written with the option of generating a ToC using links for your own local computer.
I also want it to include all section headers, so that one can literally see the overall structure of this repo in one page. If I get there, I'll add "sections" in the Syntax folder so that those can be viewed, too.
I'm not sure what the final look of the ToC should be since there will be many intermediate folder names involved and I'd like to show the structure of things without it getting too long.