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

Add Github action for autogenerating table of contents json files #3133

Merged
merged 13 commits into from
Jan 24, 2025

Conversation

Blargian
Copy link
Member

@Blargian Blargian commented Jan 23, 2025

Summary

Adds a Github action for generating table of contents .json files. These will be used to automatically generate table of contents tables on the landing pages.

Updates the current script to be able to:

  • accept arg --dir
  • generate one table of contents file for all files in a folder and it's subfolders (eg - as we would need for interfaces/formats with arg --single-toc)
  • generate one table of contents per folder (the usual use case, default)

Future improvements:

  • Extend the script to be able to accept a single file which will list directories to generate for and whether to do a single toc or one per subdirectory. eg:
/en/cloud/manage
/en/interfaces/formats --single-toc

Our folder structure's aren't great so for the time being we will add folders one by one.

Checklist

@Blargian Blargian changed the title [Draft] Add Github action for autogenerating table of contents files [Draft] Add Github action for autogenerating table of contents json files Jan 23, 2025
@Blargian
Copy link
Member Author

Blargian commented Jan 23, 2025

Notes for self:

So, it works - toc.json is generated. This will work for docs on the ClickHouse/clickhouse-docs repo, we can just commit the added files when the workflow runs. However, the problem is that we have any files from the ClickHouse/ClickHouse repo in .gitignore. So the question now is do we make toc.json which is generated in these folders an exception and commit them to this repo? This is problematic I guess as we copy content across during build - they would get overwritten I assume. On the other hand, we wanted to improve that aspect of the build process and use something like rsync (see #3087)

Alternative solutions:

  • copy all table_of_contents files to their own folder maybe named as interfaces_formats_toc.json for example rather than just one toc.json in each folder. I don't like that solution much.
  • have blank toc.json files in the ClickHouse/ClickHouse docs folders and just populate them from the action.

update 1: Have ended up going for a solution where we will store the table of contents files in a specific directory on this repo. Still need to figure out how we will generate the links to the files in the table of contents relative to the file which will use toc.json

For example:

  • We have docs/en/interfaces/formats and we add to the github action line python -u ./scripts/table-of-contents-generator/toc_gen.py --dir="docs/en/interfaces/formats" --single-toc --out="table-of-contents-files" --ignore "_snippets"
  • This outputs docs_en_interfaces_formats_toc.json at the table-of-contents-files directory.
  • However to be useful it should contain, as an example, for Arrow some property {"link" : "Arrow/Arrow.md"}. I already added a dir property which would have docs/interfaces/formats/Arrow/Arrow.md so I guess it's a case of just knowing where to cut that string. I could add another arg to the script such that you could pass --base "docs/interfaces/formats" and it could use that to know where to cut the string.

Blargian and others added 2 commits January 24, 2025 22:53
@Blargian Blargian changed the title [Draft] Add Github action for autogenerating table of contents json files Add Github action for autogenerating table of contents json files Jan 24, 2025
@Blargian Blargian marked this pull request as ready for review January 24, 2025 22:21
@Blargian Blargian merged commit dbf34ba into ClickHouse:main Jan 24, 2025
3 of 5 checks passed
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

Successfully merging this pull request may close these issues.

2 participants