Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Quick 'python -m pygame.docs', more testing
- Loading branch information
Ankith
committed
Dec 26, 2021
1 parent
6936e17
commit 7e1a6d9
Showing
3 changed files
with
60 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,38 @@ | ||
# python -m pygame.docs | ||
|
||
try: | ||
import util | ||
except ModuleNotFoundError: | ||
import docs.util as util | ||
util.open_docs() | ||
import os | ||
import webbrowser | ||
from urllib.parse import quote, urlunparse | ||
|
||
|
||
def _iterpath(path): | ||
path, last = os.path.split(path) | ||
if last: | ||
for p in _iterpath(path): | ||
yield p | ||
yield last | ||
|
||
|
||
# for test suite to confirm pygame built with local docs | ||
def has_local_docs(): | ||
pkg_dir = os.path.dirname(os.path.abspath(__file__)) | ||
main_page = os.path.join(pkg_dir, "generated", "index.html") | ||
return os.path.exists(main_page) | ||
|
||
|
||
def open_docs(): | ||
pkg_dir = os.path.dirname(os.path.abspath(__file__)) | ||
main_page = os.path.join(pkg_dir, "generated", "index.html") | ||
if os.path.exists(main_page): | ||
url_path = quote("/".join(_iterpath(main_page))) | ||
drive, rest = os.path.splitdrive(__file__) | ||
if drive: | ||
url_path = "%s/%s" % (drive, url_path) | ||
url = urlunparse(("file", "", url_path, "", "", "")) | ||
else: | ||
url = "https://www.pygame.org/docs/" | ||
webbrowser.open(url) | ||
|
||
|
||
if __name__ == "__main__": | ||
open_docs() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters