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

Feature request / question: automatic collection of doc pages entry #103

Open
charleskawczynski opened this issue Apr 25, 2020 · 5 comments

Comments

@charleskawczynski
Copy link

This is more of a request / question. I'd like to know if this added feature is something that could be incorporated into Literate, or if it's better for Documenter, or just create a separate package.

The gist of the feature (pages_array) is that the nested pages array of Pair's is automatically determined from a given directory tree with .jl literate tutorials. For example, assuming a literate_examples folder in the package, the generated markdown files are grabbed from

# After generating markdown files in `generated_dir` directory
tutorials_generated = [joinpath(root, f) for (root, dirs, files) in Base.Filesystem.walkdir(generated_dir) for f in files]
tutorials_md = filter(x -> endswith(x, ".md"), tutorials_generated)
tutorials_md = map(x -> String(last(split(x, joinpath("docs", "src")))), tutorials_md)

tutorials = pages_array(tutorials_md) # Main feature function

pages = Any[
    "Home" => "index.md",
    "Installation" => "Installation.md",
    "Tutorials" => tutorials,
    ...
]
@johnnychen94
Copy link

johnnychen94 commented Apr 25, 2020

FYI, I've made a package DemoCards that handles a similar task. A live example can be found at https://juliaimages.org/latest/democards/examples/

I do have plans to support this feature there: JuliaDocs/DemoCards.jl#27

@charleskawczynski
Copy link
Author

charleskawczynski commented Apr 26, 2020

Thanks for the info! I may just make this a separate package since I'd like to keep a light set of dependencies. I'll do that for now and see if it can be incorporated here or in Documenter. Update: I've created the package AutoPages.jl.

@fredrikekre
Copy link
Owner

This seems like a common enough pattern that I also use myself so might make sense to add the functionality here.

@fredrikekre
Copy link
Owner

Of course, you can already compose it pretty easily with broadcasting:

pages = readdir("tutorials-src"; join=true)
Literate.markdown.(pages, out)

@charleskawczynski
Copy link
Author

Ok, thanks. I've added some tests and useful functionality. Feel free to grab/modify whatever from AutoPages.jl.

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

3 participants