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

Add mkdocs documentation #639

Merged
merged 10 commits into from May 10, 2019
Merged

Add mkdocs documentation #639

merged 10 commits into from May 10, 2019

Conversation

stnevans
Copy link
Contributor

@stnevans stnevans commented May 9, 2019

Given that FEATURES.md isn't comprehensive documentation, I thought it might be helpful to have every command documented. I created some documentation using mkdocs for every command we currently have that is an ArgparsedCommand.
I also created some rough categories and put all commands into one of them. These could probably be improved.

If you want to see what the current version looks like, here it is: https://browserpwndbg.readthedocs.io/en/docs/

This was mostly done by a very ugly hacked-together script, so there might be some errors I missed. If there are any, they should be pretty small though. In the future, we should also improve the commands by adding pictures where useful.

@stnevans stnevans requested a review from disconnect3d May 9, 2019 03:38
@stnevans stnevans added enhancement For enhancements to existing features documentation labels May 9, 2019
@disconnect3d
Copy link
Member

Does it mean the docs can be regenerated via a script and just "put as is" into the readthedocs?

We should probably aim for that (?)

@stnevans
Copy link
Contributor Author

You don't need to do anything to generate them. For readthedocs, you just create a new project, set the and make the url point to this repository. It would then generate what I linked.

@disconnect3d disconnect3d merged commit 4696c4d into pwndbg:dev May 10, 2019
@stnevans
Copy link
Contributor Author

Just going to put the hacky script here for now:

for command in pwndbg.commands.commands:
        if "Argparsed" in str(command):
            doc_str = "## Command: " + command.__name__ + " ##\n"
            docs = gdb.execute(command.__name__ + " -h", to_string=True,from_tty=False)
            docs_split = docs.split("\n")
            doc_str += "```\n"+docs_split[0] + "\n```\n"
            val = 2
            #Parse description
            for i in range(2,len(docs_split)):
                val = i
                if "positional arguments:" in docs_split[i] or "optional arguments:" in docs_split[i]:
                    break
                doc_str += docs_split[i] + " "
            doc_str += "\n\n"

            #Parse positional args
            val2 = val
            if "positional arguments:" in docs_split[val]:
                val+=1
                doc_str += "| Positional Argument | Info |\n"
                doc_str += "|---------------------|------|\n"
                for i in range(val,len(docs_split)):
                    val2 = i
                    if "optional arguments:" in docs_split[i]:
                        break
                    if " " not in docs_split[i]:
                        continue
                    temp = docs_split[i].strip()
                    name = temp[0:temp.index(" ")]
                    info = temp[temp.index(" "):].strip()
                    
                    doc_str += "| " + name + " | " + info + " |\n"
                doc_str += "\n"
                
            #Parse optional args
            optstart = val2
            if "optional arguments:" in docs_split[val2]:
                val2 += 1
                doc_str += "| Optional Argument | Info |\n"
                doc_str += "|---------------------|------|\n"
                for i in range(val2,len(docs_split)):
                    if i - optstart > 1:
                        print(command.__name__ + " might need manual fixing")
                    val2 = i
                    if " " not in docs_split[i]:
                        break
                    
                    temp = docs_split[i].strip()
                    args = temp.split(",")
                    if len(args) > 2:
                        print("Manually fix " + command.__name__)
                        continue
                    #Get the long argument name
                    start=0
                    if len(args) > 1:
                        start = 1
                    temp = args[start].strip()

                    name = temp[0:temp.index(" ")]
                    info = temp[temp.index(" "):].strip()
                    
                    doc_str += "| " + name + " | " + info + " |\n"
                doc_str += "\n"
                
            #Add anything after args (Typically examples.)
            for i in range(val2,len(docs_split)):
                doc_str += docs_split[i] + "\n"
            #with open("/home/user/Desktop/github/browserpwndbg/docs/commands/"+command.__name__ + ".md","w") as file:
                #file.write(doc_str)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation enhancement For enhancements to existing features
Development

Successfully merging this pull request may close these issues.

None yet

2 participants