pawn-lang / samp-stdlib

The San Andreas Multiplayer Pawn Standard Library Package - designed for the sampctl package management system.
http://sampctl.com
48 stars 30 forks source link

Documented default SA:MP includes. #4

Open Y-Less opened 6 years ago

Y-Less commented 6 years ago

Basically combine this, with permission:

http://forum.sa-mp.com/showthread.php?t=649045

Southclaws commented 6 years ago

I actually noticed this when checking packages.sampctl.com and was going to contact the author.

It would be useful, and when the docgen tool mentioned in Southclaws/sampctl#106 is introduced, it could be updated to use the newer syntax (or I could implement XML parsing into the docgen for XML style docs)

Dayvison commented 6 years ago

This can be done using this and this code:

import requests
from bs4 import BeautifulSoup

check = True;
wikiurl = "http://wiki.sa-mp.com/wiki/";
function_name = "";

while check == True:
    print("\nInput function name to search in wiki ");
    function_name  = input();
    r = requests.get(wikiurl + function_name);
    s = r.content;
    soup = BeautifulSoup(s,"html.parser");

    try:
        description = soup.find_all("div",{"class":"description"});
        print("\nDescription\n");
        print(description[0].text);

        try:
            params = soup.find_all("div",{"class":"parameters"});
            print("\nParameters\n");
            print(params[0].text);

        except IndexError:
            print("\nInvalid Function specified");
        try:
            example_code = soup.find_all("pre",{"class":"pawn"});
            print("Example code\n");
            print(example_code[0].text);
        except IndexError:
            print("There is no example code available for this function");    

    except IndexError:
        print("No results found check your function name (case sensitive)");

    print("\n\n\nDo you want to search more?(Y/N)");
    t = input();

    if t == "n" or t == "N":
        check = False;

I really don't remember who did this

Southclaws commented 6 years ago

Thanks! That will definitely come in handy.

Side note: I've just updated the repo with tagged releases dating back to 0.3z libraries. Master branch will contain RCs so I encourage sampctl users to adopt version tags to future-proof themselves.