简体   繁体   中英

How to embed existing example from GitHub into my markdown documentation using Znai

I document usage of my API and want to refer to other people examples from GitHub repositories.

How do I include content of a file from GitHub into my documentation using Znai?

In Znai you can specify lookup locations inside lookup-paths file. One of the supported locations is HTTP location like in this example: https://testingisdocumenting.org/znai/flow/lookup-paths#http-lookup-location

For example, to include a content from a repo I have following entry in my lookup-paths file

https://raw.githubusercontent.com/testingisdocumenting/webtau/master

Once lookup-paths is set, use include-file plugin and embedded a file content from the repo

:include-file: webtau-data/src/main/java/org/testingisdocumenting/webtau/data/Data.java

Or use other plugins like include-groovy to extract a specific method body

:include-groovy: webtau-data/src/test/groovy/org/testingisdocumenting/webtau/data/DataCsvTest.groovy {
  entry: "validateTestCsvTable"
}
table.should == ['id' | 'absolute' | 'number' | 'comment'] {
                _______________________________________________
                'id1' | 'yes'      | '12'     | 'what can you say'
                'id2' | 'no'       | '24'     | 'fourth' }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM