Hosting Your Documentation on GitHub
00:00
Host Your Documentation on GitHub. At this point, you’ve completed your toy calculator
’s project documentation, which was partly auto-generated from the docstrings in your code. In this step, you’ll deploy your documentation to GitHub and add additional files that should be part of a complete Python project documentation.
00:21 While you could host the documentation on any static file hosting service, here you’ll learn how to do it using GitHub Pages. As a developer, you probably already have a GitHub account, and the platform also offers some excellent features for adding additional parts to your project documentation from boilerplate.
00:41 If you’re already hosting your Python project code on GitHub, then you can skip this section and continue to the next video, which covers deploying your documentation.
00:51
If you don’t have a GitHub repository for your project yet, then create a new repository through the GitHub web interface. Initialize it without a README.md
file so that it starts empty, and then copy the URL of the repository.
01:13 Back in your terminal, initialize a local Git repository for your Python project. After initializing an empty Git repository at your project root, you can next add a URL to your GitHub repository as a remote, following the format seen in the slide on-screen.
01:34 Here’s the command for the repo that you saw created earlier on.
01:45
Before adding any files to the Git repository, it’s a good idea to create a .gitignore
file. As the name implies, this allows Git to ignore files and folders that you specify.
01:59
In this case, creating an entry to ignore the Python virtual environment created earlier in the course and another to ignore any __pycache__
files.
02:13 With this file saved, you can now add all project files, create a commit for them,
02:28 and push everything to your remote. Note that you may need to log into GitHub for the final command and the route that you take to do so will depend on how you access GitHub.
02:44
Also take note that your local default branch for Git might be called master
instead of main
. If that’s the case, then you can rename your local branch as seen on-screen.
02:58 After this, you can push again to send your project files to your remote repository. Next, you can push the documentation you built to a particular branch on your repository, immediately making it available for users to browse online.
03:13 And that’s what you’ll see in the next part of the course.
Become a Member to join the conversation.