Suggestion JavaDoc BBCode

Discussion in 'Community Feedback and Suggestions' started by Michel_0, Aug 11, 2018.

  1. Hi there,

    i want to suggest something, which is annoying me (and surely many others) since a long time.

    If you want to post a JavaDoc reference nowadays, you need to do following steps:
    1. Open the JavaDoc website
    2. Search for or navigate to what you're actually looking for
    3. Copy its link
    4. Paste the link in your post
    5. Modify the text to see the full qualified name only
    Finally you made it. A short example of what i mean:
    But it doesn't need to be that complicated!

    So here comes my suggestion:
    A BBCode, where you put the full qualified name of an object or method and it will be displayed as JavaDoc link.
    Example:
    • [jdoc]org.bukkit.Server#shutdown[/jdoc]
    This would make the life much easier and saves a lot of time when answering plugin development questions.

    Of course this should only be limited to objects & methods of the spigot & bukkit API.
    Since you need to pass parameter types for full qualified names, there must be an attachment like in the JavaDoc link like:
    • No parameters: [jdoc]org.bukkit.Server#shutdown--[/jdoc]
    • One string parameter: [jdoc]org.bukkit.Server#broadcastMessage-java.lang.String-[/jdoc]
    • ... just like the JavaDoc links
    I doubt, that there is a xenforo plugin already, which can do this, so would this even be possible option for spigot to realize?
     
    • Like Like x 1
    • Useful Useful x 1
  2. Would love that feature!
     
  3. If there exist an xenforo-addon for this we might have a little chance of this being implemented.
    Otherwise, the answer is probably no.

    I like the suggestion though, it would make liking to certain stuff a lot easier when helping people.
     
  4. Sounds pretty cool. It has my vote, why not? :)
     
  5. I support it. If there is no addon already, there sure as hell is a developer who is able to do it.
     
  6. Relating this requested feature, i just remembered something already active:

    Basic lava.lang objects already DO have an link (it adds some "allinurl" google search link).
    Code (Java):
    String linkIt = "<- klick the object type String";
    https://xenforo.com/community/help/bb-codes/ only sais: "highlighting the syntax where possible".
    Does spigot use another Java syntax xenforo plugin or is it just the default highlighting?
     
  7. Will be amazing as if they add that :eek:
     
  8. Since this thread is 2 weeks old now and we didn't receive any official reply from spigot staff, i'll tag some mods:
    @2008Choco @mathhulk @Benz56
    • Does anyone of you know, if the automatic links in [CODE] tags is a default xenforo feature, or do you guys got an extension / plugin for that?
    • Do you know any other ways how this can be done as simple as possible?
    • Do you see any chance for this feature?
    • Who could actually make a official statement / who whould we need to ask in this case?
     
  9. 2008Choco

    Junior Mod

    md_5. Moderators take no action in the design of the website whatsoever.
     
  10. md_5

    Administrator Developer

    Part of a plugin
    No idea, personally I don't find copy pasting a URL difficult, it doesn't need to be all nicely formatted.
    The amount of people that can actually remember random API things exactly is pretty small.

    For example if I said how to merge a block state, is anyone on the site gonna go, ah yes its

    [jdoc]org.bukkit.block.data.BlockData#merge-org.bukkit.block.data.BlockData-[/jdoc]
    Without actually just using the search function on the javadoc page?

    https://hub.spigotmc.org/javadocs/s...a.html#merge-org.bukkit.block.data.BlockData-


    Even your broadcast message example, is anyone actually going to remember they need to type

    [jdoc]org.bukkit.Server#broadcastMessage-java.lang.String-[/jdoc]


    If you want it, feel free to write an XF plugin for it.


    E: and these are simple API things, vs e.g.

    [jdoc]org.bukkit.Server#createInventory-org.bukkit.inventory.InventoryHolder-org.bukkit.event.inventory.InventoryType-java.lang.String-[/jdoc]

    It took me more work to type that than copy paste the url
     
    • Funny Funny x 1
  11. Hmm you're right. If a full qualified name must be provided, it's quite complicated to use.

    It would be much better if it would be like the list when tagging people, based on this list allclasses.
    E.g. a user types Ageable, a list of org.bukkit.block.data.Ageable and org.bukkit.entity.Ageable will show up.
    You simply click one of these and got a nicely formatted JDoc link.
    This would only support classes, no methods and fields yet, but that's the first step.

    However i guess we're talking about a custom plugin now i guess.
    If someone of the community would develop such a plugin, is there a chance it actually will be used in here when approved and tested as safe and reliable?
     
  12. It took about 3 hours to make a prototype implementation.
    Could be faster, but i haven't written HTML & JS for a while...

    This webpage loads all classes listed here and provides a list of suggestions.
    I'll add some more stylish CSS stuff later on.
    Code (Javascript):
    <!DOCTYPE html>
    <html>
      <head>
        <title>JavaDoc AutoComplete</title>
        <meta name="author" content="Michel_0" />
        <script type="text/javascript">
          function JDoc() {
            function JRef(name, link) {
              this.name = name;
              this.link = link;
              this.getName = function() {
                return this.name.split(".")[this.name.split(".").length - 1];
              };
            }
            this.classes = new Array();
            this.xhr = function(url, type, payload, callback, callparam) {
              var httpReq = new XMLHttpRequest();
              httpReq.onreadystatechange = function() { callback(httpReq, callparam); };
              if (type.toUpperCase() == "GET") {
                httpReq.open("GET", url);
                httpReq.send(null);
              } else if (type.toUpperCase() == "POST") {
                httpReq.open("POST", url);
                httpReq.send(payload);
              } else {
                throw "Not supported yet!";
              }
            };
            this.parseResult = function(httpReq, instance) {
              if (httpReq.readyState == 4 && httpReq.status == 200) {
                var doc = new DOMParser().parseFromString(httpReq.responseText, "text/html");
                var list = doc.getElementsByTagName("UL")[0].getElementsByTagName("LI");
                for (var i = 0; i < list.length; i++) {
                  var ref = list[i].getElementsByTagName("A")[0];
                  instance.classes.push(new JRef(ref.title + "." + ref.textContent, ref.getAttribute("href")));
                }
              }
            };
            this.findMatches = function(input) {
              var list = new Array();
              if (input.value.length >= 1) {
                for (var i = 0; i < this.classes.length; i++) {
                  if (this.classes[i].getName().substring(0, input.value.length) == input.value) {
                    list.push(this.classes[i]);
                  }
                }
              }
              this.attachMatches(input, list);
            };
            this.attachMatches = function(input, list) {
              if (input.suggestions != null) {
                input.parentElement.removeChild(input.suggestions);
                input.suggestions = null;
              }
              if (list.length >= 1) {
                var suggestions = document.createElement("DIV");
                for (var i = 0; i < list.length; i++) {
                  var suggestion = document.createElement("DIV");
                  suggestion.textContent = list[i].getName() + " - " + list[i].name;
                  suggestions.appendChild(suggestion);
                }
                input.parentElement.appendChild(suggestions);
                input.suggestions = suggestions;
              }
            };
          }
          window.jdoc = new JDoc();
          window.jdoc.xhr("https://hub.spigotmc.org/javadocs/spigot/allclasses-noframe.html", "GET", null, window.jdoc.parseResult, window.jdoc);
        </script>
      </head>
      <body>
        <p>Find Classes from <a href="https://hub.spigotmc.org/javadocs/spigot/allclasses-noframe.html">https://hub.spigotmc.org/javadocs/spigot/allclasses-noframe.html</a>:<br /><input type="text" oninput="window.jdoc.findMatches(this);" /></p>
      </body>
    </html>
    upload_2018-8-30_23-3-25.png
    I'm just wondering if this could be more or less directly can be used as Xenforo addon?
     
    #12 Michel_0, Aug 30, 2018
    Last edited: Aug 30, 2018
    • Like Like x 1
    • Creative Creative x 1
  13. Nice one. May I host it for you?
     

Share This Page