Exporting Usage Manual: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
(Created page with "One of the issues people raised with moving the non-block/function/class specific documentation from Doxygen to wiki is that people won't have a local copy of the Usage Manual...")
 
No edit summary
Line 1: Line 1:
One of the issues people raised with moving the non-block/function/class specific documentation from Doxygen to wiki is that people won't have a local copy of the Usage Manual anymore.  To solve this I put together a little script that exports a list of pages on this wiki to the raw source which looks almost exactly the same as the doxygen source.  This script just has to be run a few times a year and then the resulting files committed to gnuradio git (the location of these files within the git repo has yet to be determined).  
One of the issues people raised with moving the non-block/function/class specific documentation from Doxygen to wiki is that people won't have a local copy of the Usage Manual anymore.  To solve this I put together a little script that exports a list of pages on this wiki to the raw source which looks almost exactly the same as the doxygen source.  This script just has to be run a few times a year and then the resulting files committed to gnuradio git (the location of these files within the git repo has yet to be determined).  


from selenium import webdriver
To use this script, just make a new Python file and run it.  There should be a new directory called "Usage Manual" created in whatever directory you ran the script from, containing a bunch of text files.  You will have to download geckodriver and change the line that points to where it is located.
from selenium.webdriver.common.keys import Keys
 
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
  import time
  import time
  import HTMLParser
  import HTMLParser

Revision as of 18:01, 31 May 2018

One of the issues people raised with moving the non-block/function/class specific documentation from Doxygen to wiki is that people won't have a local copy of the Usage Manual anymore. To solve this I put together a little script that exports a list of pages on this wiki to the raw source which looks almost exactly the same as the doxygen source. This script just has to be run a few times a year and then the resulting files committed to gnuradio git (the location of these files within the git repo has yet to be determined).

To use this script, just make a new Python file and run it. There should be a new directory called "Usage Manual" created in whatever directory you ran the script from, containing a bunch of text files. You will have to download geckodriver and change the line that points to where it is located.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import HTMLParser
import os

# Settings
pages_to_save = ['Polymorphic Types (PMTs)',
                 'Message Passing',
                 'QT GUI',
                 'Logging',
                 'Performance Counters',
                 'Tagged Stream Blocks',]

# make directory if it doesn't exist
directory_name = 'Usage Manaul'
if not os.path.exists(directory_name): # will be in the same location as this script
    os.makedirs(directory_name)
# set up web driver
driver = webdriver.Firefox(executable_path='/home/marc/Downloads/geckodriver')
for page_name in pages_to_save:
    driver.get("https://wiki.gnuradio.org/index.php/Special:Export")

    # fill in text box
    text_area = driver.find_element_by_xpath("//*[@name='pages']")
    text_area.send_keys(page_name)

    # uncheck "save as file" box
    check_box = driver.find_element_by_xpath("//*[@name='wpDownload']")
    check_box.click()

    # hit Export
    submit_button = driver.find_element_by_xpath("//*[@value='Export']")
    submit_button.click() 

    # get HTML of new page
    raw_html = driver.page_source
    start_index = raw_html.find('<page>')
    cropped_html = raw_html[start_index:]

    # save text to file
    h = HTMLParser.HTMLParser()
    cropped_html_text = h.unescape(cropped_html) # makes it so stuff like &gt shows up as a greater than sign
    file_name = "Usage Manual- " + page_name + ".txt"
    text_file = open(directory_name + '/' + file_name, "w")
    text_file.write(cropped_html_text)
    text_file.close()

driver.close()