Skip to content
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

URLs for specific API commands #3369

Closed
SafwatHalaby opened this issue Sep 5, 2016 · 14 comments
Closed

URLs for specific API commands #3369

SafwatHalaby opened this issue Sep 5, 2016 · 14 comments

Comments

@SafwatHalaby
Copy link
Member

SafwatHalaby commented Sep 5, 2016

Commit id: f7029ed

When visiting http://api-docs.cuberite.org, I'd want to have links to individual commands via the hash part of the URL. e.g. http://api-docs.cuberite.org/cPlayer.html#Freeze Should lead to the player class's Freeze command.

This should be rather simple: Each command's first HTML table cell, <td>X</td> should be changed to:

<td id="X">
  <a href="PageURL#X">X</a>
</td>

Better methods are welcome.
This may require changes to the built in APIDump plugin, which is why I posted it here.

@NiLSPACE
Copy link
Member

NiLSPACE commented Sep 5, 2016

Shouldn't be too hard to do. Just add an anker tag here: https://github.com/cuberite/cuberite/blob/master/Server/Plugins/APIDump/main_APIDump.lua#L786

@Seadragon91
Copy link
Contributor

Seadragon91 commented Sep 5, 2016

@LogicParrot Very nice idea :)

@NiLSPACE Found 2 more places where it has to be added. For constants and also for member variables.

This are the changes that I tested and they works,
Seadragon91@9678051

@madmaxoft
Copy link
Member

Careful, though. Do we want to simply mix all the symbols together (functions, constants, variables, enums) in this way, or should we prefix the anchor with something? Such as Fn<Name><OverloadIndex>? That way you could even link to a specific overload (parameter combination) of the function, in case it has more.

@madmaxoft
Copy link
Member

@Seadragon91 I don't think that's how anchoring works, AFAIK you need to use <a name="FunctionName">content</a>

@bearbin
Copy link
Member

bearbin commented Sep 5, 2016

@madmaxoft No, it does work like that, # can link to IDs. For an example, see https://book.cuberite.org

@madmaxoft
Copy link
Member

Hmm, I guess I'm too old-school :P

@madmaxoft
Copy link
Member

madmaxoft commented Sep 5, 2016

Then either convert all the anchors in the APIDump plugin output to use this syntax, or use the old one. Be consistent.

@Pokechu22
Copy link
Contributor

<a name=""> is obsolete syntax in HTML5 and id should be used instead.

@Seadragon91
Copy link
Contributor

Seadragon91 commented Sep 5, 2016

I added a table to track the function names and add _<number> to the anchor name for the overloaded functions. Also added a title, if the mouse hover over it.
Has anyone a better idea for unique anchor names, or does this fit?

Seadragon91@7a3763a

Edit:
Example of the anchor names

  1. MoveToWorld
  2. MoveToWorld_2
  3. MoveToWorld_3

@madmaxoft
Copy link
Member

madmaxoft commented Sep 5, 2016

Drop the if, use TableOverloadedFunctions[func.Name] = (TableOverloadedFunctions[func.Name] or 0) + 1 and get the first overload numbered as well as a bonus :)

@Seadragon91
Copy link
Contributor

Seadragon91 commented Sep 5, 2016

This would then add a _1 for all functions. Is that okay?

Edit: Or I copy the loop and create the table beforehand and use it then in the write loop.
Edit 2: Forget the first edit :)

@madmaxoft
Copy link
Member

It will number the functions incrementally

@Seadragon91
Copy link
Contributor

Seadragon91 commented Sep 6, 2016

Yes it will increment it, but I mean that now all functions that are not overloaded will have the _<number>.

@madmaxoft
Copy link
Member

Yes, all the anchors will have the same format, rather than having two different formats. And if a function ever receives an overload, its anchored link will still work afterwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants