knowledge-repo
knowledge-repo copied to clipboard
Improve documentation around API
Auto-reviewers: @NiharikaRay @matthewwardrop @earthmancash @danfrankj
To whom it may concern,
thank you for releasing this as open source project, it is just great!
I have a question (instead of an issue): Is there any support for machine readability? e.g. I want to use command line or programming language to get the posts with tag "data" and integrate such code snippet into a codebase, is it possible? If not, how would you recommend to extend the functionality by myself? Many thanks.
Hi @shansfolder ,
Thanks for getting in touch :). The knowledge_repo API was specifically designed to be machine-readable, and provides the basis for the web app. While all actual indexing occurs on the web app side, you can easily iterate over all posts using the API, and create your own index.
It would look something like this:
from knowledge_repo import KnowledgeRepository
repo = KnowledgeRepository.for_uri('<repo uri>')
posts = [post for post in repo if '<tag>' in post.metadata['tags']]
I'll leave this open to remind us to improve documentation around the API (which is coming soon, with the normal caveats).
Hi @matthewwardrop thanks for the reply.
I've just played around, it seems that repo = KnowledgeRepository.for_uri('<repo uri>') only works if I pass a local directory to <repo uri>. It returns error either for https://<uri for the github repo> or git://<uri for the git address>.
@shansfolder This is because 'git://' or 'https://' uris are not (yet?) supported. You can either use local paths or databases :).
@matthewwardrop I see. Thanks a lot!