Skip to content

Update Scraper Docs #1015

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 1 commit into from
Aug 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions documentation/for-contributors/generators/scraper.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# Scraper

The scraper calls into clang to generate XML and can scrape this XML for Symbols of the [Symbol Layer](./symbol-layer/README.md)
The Scraper will call into ClangSharp to generate XML from the given C headers (`GenerateXML`), and then convert the output produced by ClangSharp into symbols defined by the [Symbol Layer](./symbol-layer/README.md) (`ScrapeXML`).

The Scraper should stay quite small and easy to use, as it is also the window to all the complexity that comes from C++, Clang, header, etc. It should only bridge the XML output into the symbol layer.

## Scraping XML

To scrape XML there is a visitor that visits each XML node and outputs several symbols per node.
This is what happens in `XmlVisitor.cs`
This is what happens in `XmlVisitor.cs`, called from `ScrapeXML`.

## Generating XML using clang
## Generating XML using ClangSharp

This is what happens in `ClangScraper.cs`, which is configured using `ClangScraperConfiguration.cs`
This is what happens in `ClangScraper.cs`, which is configured using `ClangScraperConfiguration.cs`.
The XML is generated by the `ClangSharp.PInvokeGenerator` see [dotnet/ClangSharp](https://github.com/dotnet/ClangSharp) and the [PInvokeGenerator file](https://github.com/dotnet/ClangSharp/blob/main/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs).
Check XML docs for details on what methods do.