项目作者: NullEnt1ty

项目描述 :
Extract GLua API documentation from the new Garry's Mod wiki
高级语言: TypeScript
项目地址: git://github.com/NullEnt1ty/gmod-wiki-scraper.git
创建时间: 2020-04-02T08:10:01Z
项目社区:https://github.com/NullEnt1ty/gmod-wiki-scraper

开源协议:MIT License

下载


GMod Wiki Scraper

This application allows you to scrape the new Garry’s Mod wiki which can be
accessed via https://wiki.facepunch.com/gmod/.

Prerequisites

  • Node.js >= 18.17
  • npm >= 7

npm often comes bundled with Node.js so you probably won’t need to install that
separately.

Installation

  1. npm install -g gmod-wiki-scraper

Usage

  1. gmod-wiki-scraper

This will retrieve all functions, hooks, enums, etc. from the wiki and save
them as JSON files into an output directory in your current working directory.

gmod-wiki-scraper features a rudimentary cli:

  1. $ gmod-wiki-scraper --help
  2. Usage: gmod-wiki-scraper [OPTIONS]
  3. Options:
  4. --help Show help [boolean]
  5. --version, -v Print the version of gmod-wiki-scraper [boolean]
  6. --skip-global-functions Do not retrieve global functions [boolean]
  7. --skip-classes Do not retrieve classes [boolean]
  8. --skip-libraries Do not retrieve libraries [boolean]
  9. --skip-hooks Do not retrieve hooks [boolean]
  10. --skip-panels Do not retrieve panels [boolean]
  11. --skip-enums Do not retrieve enums [boolean]
  12. --skip-structs Do not retrieve structs [boolean]

API

Documentation

WIP

Examples

Retrieving a single page

This will retrieve the content of Global.Entity and parse it.

  1. import { WikiApiClient, WikiScraper } from 'gmod-wiki-scraper';
  2. const client = new WikiApiClient();
  3. const scraper = new WikiScraper(client);
  4. const page = await client.retrievePage('Global.Entity')
  5. const parsedFunctionPage = scraper.parseFunctionPage(page.content);
  6. console.log(parsedFunctionPage);

Output:

  1. {
  2. name: 'Entity',
  3. parent: 'Global',
  4. realms: [ 'client', 'server' ],
  5. description: 'Returns the entity with the matching <page>Entity:EntIndex</page>.\n' +
  6. '\n' +
  7. 'Indices 1 through <page>game.MaxPlayers</page>() are always reserved for players.\n' +
  8. '\n' +
  9. "<note>In examples on this wiki, **Entity( 1 )** is used when a player entity is needed (see ). In singleplayer and listen servers, **Entity( 1 )** will always be the first player. In dedicated servers, however, **Entity( 1 )** won't always be a valid player.</note>",
  10. arguments: [
  11. {
  12. name: 'entityIndex',
  13. type: 'number',
  14. description: 'The entity index.'
  15. }
  16. ],
  17. returnValues: [
  18. {
  19. type: 'Entity',
  20. description: "The entity if it exists, or NULL if it doesn't."
  21. }
  22. ]
  23. }