luttje / luttje/glua-api-snippets

File object `file_class` and `File` inconsistent

Open
#61 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted
Dominant language
TypeScript
Stars
45
Forks
10
PR merge metrics
No merged PRs in 30d

Description

According to the wiki [`file.Open`](https://wiki.facepunch.com/gmod/file.Open) returns a `file_class`

On the [`file_class` page](https://wiki.facepunch.com/gmod/file_class) the type name is specified as `File`:
```html
You might be looking for the "file" Library, which has the same name as this class.

This is the file object. It used used primarily to read or write binary data from files.
The default endianness is little-endian. To use big-endian you will need to provide your own functions to read and write shorts and longs.

The object is returned by file.Open.

```

This causes neither type to be correct when using file.Open:
![](https://github.com/user-attachments/assets/638e67af-3a0b-4b17-8da0-b2264271c466)
![](https://github.com/user-attachments/assets/5bfae6f1-ee19-4841-8f2f-6e5919588881)

The generated library and class annotations for reference: https://github.com/luttje/glua-api-snippets/blob/lua-language-server-addon/library/file.lua

I guess this is done on the wiki because of case insensitivity, so there can't be File and file page for the class and library respectively.

## Possible Solutions

What I can think of right now:
- Changing the wiki in some way (seems cumbersome)
- Adding a way to transform scraped data according to a list of exceptions/rules, in this case: replacing file_class with File
- Using the `name` attribute instead of the `type` attribute from the file.Open function wiki (not sure if that would be correct everywhere):
```html
The opened file object, or `nil` if it failed to open due to it not existing or being used by another process.
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the wiki definitions for file.Open and file_class with the generated library/file.lua annotations. Trace how the scraper handles the file.Open return type and class name, then regenerate the snippets and verify that both refer to the same File type without breaking other API annotations.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.