Pelles C forum

C language => Work in progress => Topic started by: TimoVJL on May 18, 2025, 04:24:44 PM

Title: win32-doc md files
Post by: TimoVJL on May 18, 2025, 04:24:44 PM
https://github.com/MicrosoftDocs/win32 (https://github.com/MicrosoftDocs/win32)
MS Win32 help files in md-format.

Test program just open zip-file and check all md-files for "api_name:" keywords.

At first might be better just to extract one folder and zip it again for testing.

One full test 58416 files.

Keyword test for keywordsint ParseFile(char *pMem, int nSize, char *szFile, int nLen, int nIdx)
{
char *pPtr, *pPtr1, *pPtr2;
pPtr = strstr(pMem, "api_name:"); // CRT
//pPtr = StrStr(pMem, "api_name:"); // shlwapi.dll
if (pPtr) {
printf("%s\t", szFile);
pPtr += 9; // pass
while (*pPtr != 10) pPtr++;
pPtr++;
pPtr1 = pPtr;
pPtr2 = pPtr;
//*(pPtr+10) = 0;
do {
while (*pPtr2 != 10) pPtr2++;
*pPtr2 = 0; // cut to newline
printf("%s ", pPtr1);
pPtr2++;
pPtr1 = pPtr2;
} while (*pPtr2 == '-');
printf("\n");
} else printf("%s\n", szFile);
return 0;
}
Title: Re: win32-doc md files
Post by: John Z on May 18, 2025, 05:03:56 PM
Thanks TimoVJL,

Got it and the entire WIN32 zip.  Will let you know.

John Z
Title: Re: win32-doc md files
Post by: Quin on May 18, 2025, 09:45:11 PM
This is absolutely incredible, thanks Timo!
Title: Re: win32-doc md files
Post by: John Z on May 23, 2025, 09:34:30 PM
Hi TimoVJL.

Here is a SQLITE3 database and some crude sample code to access it.  The DB3 file is 7Z inside of the project zip so it must be un7z'd into the application directory.  The DB contains the API NAMES your utility identified in the WIN32-docs.zip downloaded from GitHub. For each* API NAME it contains the path within the ZIP files needed to extract the .md file for the API so that the .md file can be viewed. A small dialog is used for the demo.

*This is just a first pass as the WIN32-Docs was not consistent in file naming, so there are some names it will not yet work on.  This can be handled if the project seems to be of value by making multiple queries for a given API name trying each of the various filename formats.

There is a readme in the project directory as well.

John Z
Title: Re: win32-doc md files
Post by: TimoVJL on May 24, 2025, 05:42:18 PM
A your example provide, that MS help file is just useless.

Last locally working help file is from 2019-09-05

After that, just pile of shi....
Title: Re: win32-doc md files
Post by: John Z on May 29, 2025, 12:54:40 PM
Hi TimoVJL,

It is actually worse than you might think too.

HOWEVER -
I added a few code lines to your extract program and from the new extract I have built a new database, handling all identified API_NAME files.  So it accommodates the inconsistent formats, and other issues.

The GitHub documentation was clearly (to me) done by multiple people/groups with various inconsistencies and no general oversight.  Some API_NAMES are not even API functions, many files for the same base API Name bla bla bla...

So the new DB3 takes care of everything extracted by your extract program.

I'll create the new queries needed to output the filename to extract and show, next.  Where there are multiple files for the same base API NAME the user will need to select, similar to HINT when searching a partial function name.

Another possible use of the DB is to create a treeview where the top level are the directories and child level is for the API NAMEs... easy for user to see/browse for the API function they want information on, clicking a child level item pulls the file from the zip and displays it.
Depends on how much work is to be invested in the final output.

John Z
Title: Re: win32-doc md files
Post by: TimoVJL on May 29, 2025, 02:26:26 PM
Only good thing is, that now is possible to create database for online help.
You have done great job with that MS help material.
Title: Re: win32-doc md files
Post by: John Z on May 31, 2025, 12:14:52 PM
Hi TimoVJL,

Attached is the new DB for the GitHub win32-docs.zip offline documentation.  Every API_NAME output by your extract program is accessible in the DB.

Had some clean-up to do and I'm looking for 'runs the first time" bug in my C access program.

So posting the DB now.  Later posting my access program when bug free, but I'm sure it is not really needed by most people.  Because of the complexity/inconsistency of the win32-doc using a sql 'like' command will often be the first step in getting to the document desired.

Like the 1st db the "Win32-docs\\desktop-src\\" is to be pre-appended to the SQL returns, that is the DB returns the SubDir and the actual filename.md, as before.

John Z
Title: Re: win32-doc md files
Post by: John Z on June 02, 2025, 04:21:40 PM
Here is the newest mdfiles program and MD_Files_3.db3 to use with it.

This version outputs the win32-doc.zip path for every API NAME outputted when using TimoVJL's extract utility.  Note that due to GitHub documentation inconsistencies some API NAMES are not really API NAMES, but these are still handled in this db3.  For example entering /-o shows a list to pick for example /-out yielding a filename and path as
Win32-docs\desktop-src\Midl\-out.md 

This program just shows how to get the filename and path from the db3.  It does not extract the .md file to be displayed in a suitable .md file viewer or using webview.

The .db3 is compressed with zip inside of the project zip and needs to be uncompressed before using.  The db3 file of course can be used by anyone, for anything . . . . as can this program.

John Z
Title: Re: win32-doc md files
Post by: TimoVJL on June 02, 2025, 07:57:31 PM
In Pelles C bin folder is SQLite3.dll
To create x64 SQLite3.lib
SET PATH=C:\Program Files\PellesC\bin
polib "%PATH%\SQLite3.dll" -out:SQLite3.lib
EDIT: processing .yml file can be used for external help system to open pages from MS site.
Title: Re: win32-doc md files
Post by: John Z on October 26, 2025, 01:10:27 PM
Well - Here is the next version of the mdfiles program.
I had hoped I had dropped enough hints that one of the more experienced would have created this but seems left for me  8) so here it is.

With this version one downloads the entire ZIP from from GitHub as TimoVJL mentions at the top of this topic.  For the original mdfiles program I used TimoVJL's extract program to extract API Names from it, which I then used to created a database of the names and the paths within the github zip file.  It stopped there.

Now with this new version 2.0 of mdfiles.exe it will if desired extract the selected .md for you, into the application directory.  It also can just display the selected .md file without doing any extracting to the hard disk. Of course you can copy from the display too. See Screen shots -

There is a readme.txt in the zip file along with the .exe and the api db3 file.  No sources yet as I need to figure out using the new minizip - I'm using a very old crude 2 file zip implementation and not happy about it, but I made it work.... 

John Z
Title: Re: win32-doc md files
Post by: John Z on November 06, 2025, 12:07:12 PM
The next improvement to the mdfiles program -

This adds the ability to show the .md file as .html in the browser.
Also creates a temp subdirectory under the program directory for the
files created so that it is easy to delete ones no longer wanted.  All
.md files and .html file will go into the temp directory.

The .md to .html file is using MIT License and Copyright © 2016-2024 Martin Mitáš
(http://github.com/mity/md4c) with my mods to make it work in Pelles C.

The .html file will use the systems default program to handle .html extension files.
Was going to use Timo's webview - but maybe later.

The upload only includes the .exe and a readme so use the db files from the prior post.

Input welcome and wanted.

John Z
Title: Re: win32-doc md files
Post by: TimoVJL on November 06, 2025, 01:03:09 PM
An interesting project.

To compile md4c.c, a change for it at line 100:47, && !__POCC__
    #elif defined _MSC_VER  &&  _MSC_VER > 120 && !__POCC__
Title: Re: win32-doc md files
Post by: John Z on November 06, 2025, 04:18:08 PM
Yes about what I did but a bit differently-
I added     #ifdef _PELLESC__
        #define MD_ASSERT(cond)     do {} while(0)
        #define MD_UNREACHABLE()    do {} while(0)
    #elif
at the beginning of the block there.

Flags are set to accommodate the GitHub idiosyncrasies, but
will probably work ok for any .md file.  Use the 'Convert other .md File'
button.

Here is a quick update of the program
Fixed needing the TOP button so that is now removed.

Added ability to list every name in the DB by entering an *
Hoping this makes it easier to find something -

John Z

Still need to modernize the ZIP code before posting sources.
Title: Re: win32-doc md files
Post by: TimoVJL on November 06, 2025, 07:06:38 PM
Many times is good to keep line numbers intact.

Have miniz still problems with Pelles C 13 ?

Like in this:
https://github.com/kuba--/zip (https://github.com/kuba--/zip)

EDIT: it have :(
Title: Re: win32-doc md files
Post by: Vortex on November 06, 2025, 07:14:31 PM
Hi Timo,

Mentioning about Miniz, are your referring to this project?

https://github.com/richgel999/miniz
Title: Re: win32-doc md files
Post by: John Z on November 06, 2025, 11:22:03 PM
Quote from: TimoVJL on November 06, 2025, 07:06:38 PMLike in this:
https://github.com/kuba--/zip (https://github.com/kuba--/zip)

Thank Timo!  I'll give this one a try - maybe simple enough for me to use.

John Z

Update:  An older version of this (1.19) is what I am using now.  Back in about 2020 I went through the 1.19 code and succeeded in getting it to work for Pelles C.  Now looking at this version 3.0.2 it is just as difficult under Pelles C as 1.19 was :( but structurally it has changed a lot so a file difference does not highlight changes compared to what I did in 1.19 SO it is basically going to be starting all over......   
Title: Re: win32-doc md files
Post by: John Z on November 08, 2025, 02:09:03 PM
:)
It looks like I have got 3.0.2 working in Pelles C at least for unzipping to a file or memory.

I'll need to run some tests to see if it works for zipping too.

Making progress in either case.

John Z

Update - looking nice, it was able to zip a file and both 7z and WIN zip could access it and the file was extracted intact and readable.

Title: Re: win32-doc md files
Post by: John Z on November 09, 2025, 05:25:49 PM
The completed project is posted over in User Contributions -
https://forum.pellesc.de/index.php?topic=11672.0

Cheers,
John Z