Skip to content

Add script to extract CMake function descriptions #2422

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

Merged
merged 19 commits into from
Apr 29, 2025

Conversation

will-v-pi
Copy link
Contributor

This adds a script to extract CMake functions and output them as a TSV file, similar to extract_cmake_configs.py for PICO_CMAKE_CONFIG variables

Also adds basic descriptions for all functions missing them, other than some which are set as allowed to be missing them in the script

@will-v-pi will-v-pi added this to the 2.1.2 milestone Apr 14, 2025
@will-v-pi will-v-pi requested a review from kilograham April 14, 2025 15:47
@will-v-pi will-v-pi force-pushed the extract-cmake-functions branch 2 times, most recently from 2b4a2d0 to b9dd179 Compare April 14, 2025 17:10
@lurch
Copy link
Contributor

lurch commented Apr 14, 2025

Looks like 79b3eb2 probably shouldn't be in this PR?

EDIT: Discussed offline. Reasons. 😉

@will-v-pi will-v-pi force-pushed the extract-cmake-functions branch from b9dd179 to 42388f6 Compare April 15, 2025 08:31
@will-v-pi
Copy link
Contributor Author

(Rebased onto #2423 for now, will rebase onto develop once that's merged)

@will-v-pi will-v-pi force-pushed the extract-cmake-functions branch from 1a4906c to 171daf7 Compare April 15, 2025 15:29
@kilograham
Copy link
Contributor

would be good to see some sample PDF output for these... i wonder if there is a simple way we can deal with parameters... maybe treating any line which starts with a capitilized "SOME_VAR description" as a parameter

@kilograham kilograham self-assigned this Apr 23, 2025
@lurch
Copy link
Contributor

lurch commented Apr 24, 2025

Looking at the latest TSV file that this generates, each row is indeed now a single line ( 💯 ), but there seems to be multiple \n\n at the start and end of each description, which seems a bit superfluous?

EDIT: Which you could probably fix with something like:

desc = re.sub(r'^(?:\\\\n)*(.+?)(?:\\\\n)*$', r'\1', desc)

@lurch
Copy link
Contributor

lurch commented Apr 24, 2025

IMHO the extracted TSV file is looking much better now, thanks 👍 (If you've not already seen it, there's a really nice "Rainbow CSV" extension for VSCode which gives the different columns different colours, which is pretty handy!)

But the descriptions still have things like:

... included)\n\nDEFAULT_ALARM_POOL    - default alarm pool setup;\nPRINTF                - full printf ...

so perhaps it's worth doing desc = re.sub(' +', ' ', desc) too?

@will-v-pi
Copy link
Contributor Author

IMHO the extracted TSV file is looking much better now, thanks 👍 (If you've not already seen it, there's a really nice "Rainbow CSV" extension for VSCode which gives the different columns different colours, which is pretty handy!)

But the descriptions still have things like:

... included)\n\nDEFAULT_ALARM_POOL    - default alarm pool setup;\nPRINTF                - full printf ...

so perhaps it's worth doing desc = re.sub(' +', ' ', desc) too?

I think it's better to leave those spaces in, as they align the - for each line if you do print them out in full, or they can just be compressed to one space by downstream tooling

Also print warnings for functions missing descriptions
They don't take a TARGET argument
brief - a brief description

brief_nodesc - a brief description, which should be excluded from the full description

param - a parameter and it's description
Detail unsupported characters

ret -> desc

Add some manual sorting of tools/cmake functions

Use dicts for all_functions items
Adds entries to the TSV beginning with `_desc_` for the group name (in the brief column) and description
lurch
lurch previously approved these changes Apr 28, 2025

# Group descriptions
group_names_descriptions = {
'boot_stage2': ('Boot Stage 2', 'CMake functions to create stage 2 bootloaders'),
Copy link
Contributor

Choose a reason for hiding this comment

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

I had thought to add these in the CMake files themselves, but this is certainly fine for now

@kilograham kilograham merged commit 6e31579 into develop Apr 29, 2025
8 checks passed
@kilograham kilograham deleted the extract-cmake-functions branch April 29, 2025 16:09
@kilograham
Copy link
Contributor

  • I will add some more docs as a separate PR
  • @will-v-pi it would be nice to (perhaps manually) tag the functions as rp2040 or rp2350 in the SDK book

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.

3 participants