How can I display existing source code files within MkDocs? I want to include the files directly from another GitHub repository in code blocks without reformatting them so updated files will be shown in the MkDocs document.
sample_code.py
def fn():
pass
Using MkDocs with Snippets extension. Snippets and/or off-line processing require files to be available locally which is explained in the Pro Git book Git Tools Submodules section.
Include full file path even if the file in the same folder:
index.md
.
```python
--8<-- "docs/sample_code.py"
```
.
Create the source code file:
sample_code.py
def fn():
pass
Add the extension to mkdocs configuration file:
mkdocs.yml
site_name: Demo
markdown_extensions:
- pymdownx.snippets:
nav:
- Demo: index.md
Output
.
def fn():
pass
.
Related
This pylance GH link renders the new-issue page as
whereas my own new-issue page is rendered as
which, I guess, is using some kind of blank-issues
per GH doc, I need to add a config.yml file to the .github/ISSUE_TEMPLATE folder.
However, there isn's a config.yml file in pylance GH .github/ISSUE_TEMPLATE folder.
Is the config.yml file what I need for the new-issue page pointed out by the red arrow? or I misunderstood the GH doc?
The config.yml is used to generate links outside of Github. For example to invite users to use stackoverflow to ask question instead of the github issues.
To add template choices (as you have in the red square), you will have to add template files in the form of .md files in the .github/ISSUE_TEMPLATE folder. You can see example of those template files in the pylance GH .github/ISSUE_TEMPLATE folder
I uploaded my android studio project in java on GitHub but it is not showing languages section.
How do I add languages section. And why GitHub failed to detect languages used in repository?
Repository link - https://github.com/QAZIMAAZARSHAD/Bank-Android-App
https://i.stack.imgur.com/6C3il.jpg
These files are considered documentation by Linguist because they're in the app/ folder. You can use the following.
make a file name called .gitattributes this file will override that behavior and paste the following in that file.
app/* linguist-documentation=false
app/* linguist-vendored
I am hosting a static application on GitHub pages. My application structure is like this - I have some front-end facing files, and some Python files that are run periodically to get the data for the front-end, but should not be user-facing:
index.html
/js
index.js
vendor/
/css
/data
get_data.py
How can I stop everything in data/ being publicly available on the website?
You have two main options:
Option 1: Rename your data directory to _data.
Jekyll ignores files and directories that start with an underscore. You could also create a top-level _backend directory and then move your data directory into that.
Option 2: Configure your Jekyll to exclude the data directory.
You can add an exclude setting to _config.yml to tell Jekyll to ignore your data directory.
From the configuration documentation:
Exclude
Exclude directories and/or files from the conversion. These exclusions
are relative to the site's source directory and cannot be outside the
source directory.
exclude: [DIR, FILE, ...]
Googling "jekyll underscore directory" returns a ton of results, including this one which explains all of the above: https://help.github.com/articles/files-that-start-with-an-underscore-are-missing/
I have a GitHub repo with some python code and some text files. However, I want to add some Golang code to my project.
So basically my issue is that I'm confused on where to set my GOPATH so I can work with Go source files in the same place that I work on python files. Do I set my GOPATH to my repo path, then setup the \src\github.com\user\ directory and put my Go code there? Do I put Grandzam where user is, or leave it alone because someone else is working with me on the repo?
https://golang.org/doc/install Test your installation is what I am confused about.
I would recommend setting up an environment consistent with the recommendations in the "Organizing your code" section of the language documentation.
First, choose a top level directory (I tend to use ~/devel), and set the value of your GOPATH environment var to that location, and add the GOPATH/bin dir to your path. Put it in your the appropriate session startup file (~/.bash_profile or similar). In my case, I would put these lines in that file:
export GOPATH=$HOME/devel
export PATH=$GOPATH/bin:$PATH
Quoting from the documentation:
To give you an idea of how a workspace looks in practice, here's an example:
bin/
hello # command executable
outyet # command executable
pkg/
linux_amd64/
github.com/golang/example/
stringutil.a # package object
src/
github.com/golang/example/
.git/ # Git repository metadata
hello/
hello.go # command source
outyet/
main.go # command source
main_test.go # test source
stringutil/
reverse.go # package source
reverse_test.go # test source
golang.org/x/image/
.git/ # Git repository metadata
bmp/
reader.go # package source
writer.go # package source
... (many more repositories and packages omitted) ...
Next, clone your git repo into the appropriate path under the $GOPATH/src tree. In my case it would be $GOPATH/src/github.com/user/repo.
Now you should be all set to work on both go and python code without much trouble.
While creating GitHub Pages for my project I was suggested to import existing README.md as the project's homepage. Later, I merged gh-pages with master and ended up with both index.html and README.md.
The "problem" is that the updates to README.md won't affect index.html. Is there any simple way to keep them in sync? Preferably with zero Jekyll knowledge...
Here's what I came up with, in case someone is interested.
Typically I write HTML using Jade preprocessor, and luckily it does support GitHub Flavored Markdown which is the language README.md is written in. So my steps where as following:
Translate index.html generated by GH Pages to Jade. I used online html2jade tool;
Save the output to index.jade;
Locate section block in the resulting markup in index.jade and replace its entire content with:
section
include:md README.md
Run jade index.jade which produces new, automatically generated index.html;
Commit both files to gh-pages.
See example in this commit on GitHub.