Skip to content

Conversation

jf205
Copy link
Contributor

@jf205 jf205 commented Oct 26, 2020

This PR adds a process for generating query help documentation to use in on the CodeQL docs site so that we can move away from the Wiki.

For this new process I've added:

  • a Python script that renders the query help as markdown. It does the following:

    • runs codeql generate query-help for the queries in a selected query suite for all the languages we currently support to produce a markdown file for each query help article
    • inserts metadata, a link to the query source file and information about the query suites the query is selected by into each article
    • create toc-<lang>.rst files which list the query help files for each language. These toc files are part the Sphinx project to render the query help as HTML.
  • files needed to add a new Sphinx project. This includes:

    • a configuration file. It's similar to the conf.py files used in our other Sphinx docs, but it specifies recommonmark as an extension to build HTML from markdown.
    • a landing page for the project
    • a landing page for the query help for each language. These landing pages use includes to insert the TOCs generated by the docs generation script.
  • an actions workflow file which:

    • checks out the CodeQL repos
    • obtains and sets up the CodeQL CLI
    • runs the docs generation script
    • uses a Sphinx action to convert the markdown file to HTML.
    • uploads the HTML artifacts to the actions workspace. We can then download the artifact for use on the site.

You can see a preview of the HTML output here.

@jf205 jf205 force-pushed the query-help-tests branch 4 times, most recently from d41dd2d to 15fb257 Compare October 28, 2020 13:21
@jf205 jf205 changed the title [WIP] Add query help to Sphinx project Add new process to generate query help for help site Oct 28, 2020
@jf205 jf205 requested a review from adityasharad October 28, 2020 16:28
@jf205 jf205 changed the title Add new process to generate query help for help site [docs] Add new process to generate query help for help site Oct 28, 2020
@jf205
Copy link
Contributor Author

jf205 commented Oct 28, 2020

When I ran this workflow with just the "code-scanning" and "security-extended" query suites it took about 12 minutes. I added "security-and-quality" in 74d274c and now it takes 32 minutes 🤦

@jf205 jf205 marked this pull request as ready for review October 28, 2020 16:58
@jf205 jf205 requested a review from shati-patel as a code owner October 28, 2020 16:58
@jf205 jf205 removed the request for review from shati-patel October 28, 2020 16:58
@jf205 jf205 changed the base branch from main to rc/1.26 November 7, 2020 10:43
@jf205
Copy link
Contributor Author

jf205 commented Nov 7, 2020

@sj, @esbena: the markdown files generated by the script now have filenames based on the id property. The short language code (e.g. cpp, cs etc) isn't included in the name because the files are already sorted into language-specific directories. See this preview for examples of the URLs for each query help page. Please let me know if this works for you 😸

@esbena
Copy link
Contributor

esbena commented Nov 10, 2020

Thanks. I think using id for file names is the right choice, but I think you should keep the short language code as well. There is nothing elsewhere that prevents queries from diverging from the convention of having a short language code as a prefix of the id.

@jf205 jf205 force-pushed the query-help-tests branch 2 times, most recently from 911a41b to 6dbe5b6 Compare November 20, 2020 10:56
@jf205
Copy link
Contributor Author

jf205 commented Nov 20, 2020

Thanks. I think using id for file names is the right choice, but I think you should keep the short language code as well. There is nothing elsewhere that prevents queries from diverging from the convention of having a short language code as a prefix of the id.

Ok, done 👍

For each query help page, I've also added a line at the bottom of the query metadata section that notes which code scanning query suite the query appears in.

@jf205
Copy link
Contributor Author

jf205 commented Nov 30, 2020

We are nearing the end of the content work for the new docs site, so I'd love to move this along if possible. It's not super important to get the processes merged, but the output does need to be finalized before we use it on the new site.

With that in mind I'd like to pull in a review from @sj to make sure that we are on track from a product point of view please.

@jf205 jf205 requested a review from sj November 30, 2020 19:38
Copy link
Contributor

@shati-patel shati-patel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay, this looks great @jf205! 🎉 I've added a couple of minor (mostly optional) suggestions and questions.

I haven't looked too closely at the script/workflow, but let me know if there's anything specific you'd like me to test or review!

jf205 and others added 2 commits December 1, 2020 13:42
Co-authored-by: Shati Patel <42641846+shati-patel@users.noreply.github.com>
@jf205
Copy link
Contributor Author

jf205 commented Dec 1, 2020

Thanks for the docs review @shati-patel. Following your comments I've:

  • reworked the main landing page so that the TOC doesn't look so odd
  • updated the titles on the landing page for each language (example)
  • changed readme.txt -> readme.md and excluded it from the build
  • Unrelated: I've also changed the sphinx builder to dirhtml. This means that the URLs for the query help articles won't have the .html extension, which i think is nicer (we already use this for the other CodeQL docs).

Copy link
Contributor

@shati-patel shati-patel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tweaks! All LGTM from a docs point of view, but I'll let someone more qualified take a look at the scripts 👀

@adityasharad
Copy link
Collaborator

Thanks! I'll do a proper review this week. I think some of the functionality you've written should eventually make its way into codeql generate query-help, and then we can run it internally against all the relevant repos, but that doesn't need to hold up this PR.

@jf205
Copy link
Contributor Author

jf205 commented Dec 2, 2020

Thanks! I'll do a proper review this week. I think some of the functionality you've written should eventually make its way into codeql generate query-help, and then we can run it internally against all the relevant repos, but that doesn't need to hold up this PR.

👍🏻 thanks @adityasharad

Merging this now 🎉

@jf205 jf205 merged commit 91c96ad into rc/1.26 Dec 2, 2020
@jf205 jf205 deleted the query-help-tests branch December 2, 2020 17:54
@adityasharad
Copy link
Collaborator

Quick follow-up PR: #4770

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

Successfully merging this pull request may close these issues.

4 participants