Git Product home page Git Product logo

Comments (22)

Razoric480 avatar Razoric480 commented on August 12, 2024 1

I'll give it a poke, sure.

from gdscript-docs-maker.

Geequlim avatar Geequlim commented on August 12, 2024

The dumped json should contains constants,functions,signals and all symbols defined in script files with javadoc liked documents and signatures.
We can make a tool to render the generated json to webpage like read the doc

from gdscript-docs-maker.

NathanLovato avatar NathanLovato commented on August 12, 2024

Thanks! But this function doesn't seem to be exposed in the editor (just rebuilt Godot).

Would you have a brief usage example? I looked for a feature like this in the editor, couldn't find one before making this tool.

from gdscript-docs-maker.

Geequlim avatar Geequlim commented on August 12, 2024

var symbols = Engine.get_singleton('GDScriptLanguageProtocol').get_workspace().generate_script_api('res://main.gd')

from gdscript-docs-maker.

NathanLovato avatar NathanLovato commented on August 12, 2024

Ah, that's why I couldn't find it! Thank you :)

from gdscript-docs-maker.

NathanLovato avatar NathanLovato commented on August 12, 2024

Got it working! Is there a way to collect the description key from the source code directly? Without that I still have to parse every file a second time from python to collect docstrings, and might as well do it all from Python (removes the need for running Godot + gdscript as a dependency)

{
    "constants": [],
    "description": "",
    "extends_class": ["GSTGroupBehavior"],
    "extends_file": "",
    "icon": "",
...
}

from gdscript-docs-maker.

Geequlim avatar Geequlim commented on August 12, 2024

from gdscript-docs-maker.

Razoric480 avatar Razoric480 commented on August 12, 2024

It should be the docstring for the class itself. It works for functions and properties, but this code:

if (const lsp::DocumentSymbol *symbol = get_symbol_defined_at_line(LINE_NUMBER_TO_INDEX(p_class->line))) {
	class_api["signature"] = symbol->detail;
	class_api["description"] = symbol->documentation;
}

seems to be returning null in dump_class_api, which means the class itself doesn't have documentation.

from gdscript-docs-maker.

Geequlim avatar Geequlim commented on August 12, 2024

from gdscript-docs-maker.

Razoric480 avatar Razoric480 commented on August 12, 2024
extends Reference
class_name GSTPath
# Represents a path made up of Vector3 waypoints, split into path segments for use by path
# following behaviors.


# Whether the path is a loop, or has its start and end disconnected and open ended
var open: bool
# The length of the full path
var length: float


# Creates a path with the provided waypoints
func create_path(waypoints: Array) -> void:
	pass

truncated. the parser returns the docstring for the function and the members, but not the class.

I've tried putting the string in a variety of places - in line with the class name, with the extends, at the end, but it's never detected. My only guess is that the class' line number is -1 or something else to indicate "does not count", which means it cannot return a proper index. That would make this a bug in the parser.

I've not debugged it, though, so that's only a guess.

from gdscript-docs-maker.

NathanLovato avatar NathanLovato commented on August 12, 2024

Ah that's why I wasn't getting any description for the scripts I tested! They only have a class docstring.

from gdscript-docs-maker.

Geequlim avatar Geequlim commented on August 12, 2024

You'd better move the documentation to the top.

from gdscript-docs-maker.

Geequlim avatar Geequlim commented on August 12, 2024

Here is an example
https://github.com/GodotExplorer/gdutils/blob/master/utils/RandomPool.gd

from gdscript-docs-maker.

Razoric480 avatar Razoric480 commented on August 12, 2024

No change - Dictionary.description is still empty.

# Represents a path made up of Vector3 waypoints, split into path segments for use by path
# following behaviors.

extends Reference
class_name GSTPath

#...

from gdscript-docs-maker.

Razoric480 avatar Razoric480 commented on August 12, 2024

LINE_NUMBER_TO_INDEX is a macro that takes the line number and -1s it.

The ClassNode's line variable is never modified, and so its default is 0 as an integer. So it tries to pass in -1 as an index to get_symbol_defined_at_line, which should return the class symbol, but clearly does not.

from gdscript-docs-maker.

NathanLovato avatar NathanLovato commented on August 12, 2024

I also have one or more GDScript files that crash the parser. We're moving to a new apartment in a few hours so I'll have to debug later, but I'll open a bug on the godot repo in a while.

from gdscript-docs-maker.

NathanLovato avatar NathanLovato commented on August 12, 2024

@Razoric480 is the class docstring bug something you could fix? If so, you can do it as part of your work for GDQuest, and open an issue and a PR on the godotengine repo

from gdscript-docs-maker.

Geequlim avatar Geequlim commented on August 12, 2024

By the way the docstring can be markdown or bbcode we are using in the class documentation xml files for C++ classes

from gdscript-docs-maker.

Razoric480 avatar Razoric480 commented on August 12, 2024

Okay, so apparently, changing a script file does not recache its contents for the GDScript server until you close and reload the project, at least not with class_name loaded files.

Turns out, that having the docstring as the first line of a GDScript does, in fact, get put into the description key of the output.

"name": "GSTPath",
  "path": "res://src/GSTPath.gd",
  "extends_class": [
    "Reference"
  ],
  "extends_file": "",
  "icon": "",
  "signature": "class GSTPath",
  "description": " Represents a path made up of Vector3 waypoints, split into path segments for use by path\n following behaviors.\n",
# Represents a path made up of Vector3 waypoints, split into path segments for use by path
# following behaviors.
extends Reference
class_name GSTPath

The question then becomes how to make it an easy to use parser. Could be a TSCN with a simple Node with some exported options (what files to document, output to what file, export template, etc) and a way to trigger the export function which you can import into your project. Might make it a bit user friendlier that way than a command line argument.

Or an EditorPlugin.

Since it requires a tool script to get the language protocol, we can't just use the -s argument and run it as a command line script.

from gdscript-docs-maker.

NathanLovato avatar NathanLovato commented on August 12, 2024

@Razoric480 I already made an EditorScript, with the instructions: https://github.com/GDQuest/gdscript-docs-maker/tree/master/godot-scripts

from gdscript-docs-maker.

NathanLovato avatar NathanLovato commented on August 12, 2024

For now it's fine by me to generate the docs that way, if we happen to do it so much we could use a plugin, it won't take long to add some bit of interface for it and turn it into a package.

from gdscript-docs-maker.

Razoric480 avatar Razoric480 commented on August 12, 2024

Noted. I did post an issue and PR for a related crashing bug, though, while testing it.

from gdscript-docs-maker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.