I am working on a port of a codebase (Java) to another language (Python), with some modifications. The Java codebase is licensed under CC BY-NC-SA. Understandably, the Python codebase will also be CC BY-NC-SA, but what's not clear to me is whether I can write a book that goes into the implementation details and theory, and sell that for commercial purposes, assuming the Python codebase is published on Github or something like that.
If your book does not contain any actual code snippets or transliterations of the code into English (i.e. code translated to sufficiently descriptive pseudo-code), but it only describes the ideas contained in the code, then your book is not a derived work in the sense of copyrights and you are not constrained in how you publish and license the book.
If the book does contain snippets of code, then it becomes a question if your use of the code in the book falls under a copyright exemption, like fair use, or not. In many countries, copyright law contains exemptions of copyright protection, allowing small portions of a copyrighted work to be copied to, for example, provide context in a critique about the work. If your code snippets fall within the criteria of such an exemption can only be definitively be determined in a court of law.