I am planning to open some my technical notes with example code snippets. Text will be in Markdown (.md) and reStructuredText (.rst) files. Output document (PDF or HTML) will be generated, let's say by Sphinx, and will be hosted on Read the Docs. Source code (md, rst and code snippets) will be hosted on Github. Flow is illustrated in the figure below.
I want to enable potential contributors contribute easily. On the other hand, I want to prohibit commercial usage. In that case how should I choose type , , ? How should I indicate licenses? Who are the copyright owners if someone contributes? I checked several online resources but couldn't find a clear solution.
Let's say that source code of text sections is licensed by , code snippets by  and final documents by . I think that I can use CC BY-NC-SA 4.0 for type . By doing so anyone can change the document but can't sell it. But what are proper choices for  and ? For , if source code of text is considered as code then I think CC BY-SA (with/with out NC) isn't suitable because usage of CC BY-SA is discouraged for code. If I choose CC BY-NC-SA for , can I use GPL for  and compile all sources to generate a output which is licensed as CC BY-NC-SA? Does this violates GPL?
Let's say that I decide which licens to use. How should I indicate licenses? I am planning to organize the source such that md and rst files are in Folder 1 and code snippets are in Folder 2. So should I create differente LICENSE file in each folder if  and  are different? Should I indicate a license (and probably copyright statement) in each file as a comment?
I would appreciate any ideas.