but then again if I redo the make process, the docs built so far removed and the process starts from beginning of documentation building.
So how do I do this? Will just putting export SAGE_KEEP_BUILT_SPKGS=yes in sage-8.4/src/bin/save-env-config suffice and if it does then how to achieve it? so far I failed to make it work.
Are you building based on Python2 or Python3? For a Python3-based build, at this stage, the documentation is known not to build.
If you want to keep some variables between shell sessions the way to do that is (depending on your shell) to set them in your local rc file for your shell (most shells will read .profile so you can put export <WHATEVER> there). This is just the general way to set environment variables.
Don't go modifying files in Sage's sources unless you know exactly what you're doing because they might get overwritten or otherwise not persist somehow.
It would be nice if SAGE_ variables like this were saved when running sage's ./configure, however.
@Iguananaut I tried something like that but i could not exactly understand what the dochtml.log https://pastebin.com/KxscKcMB meant in its messages even after following the suggestion.
I'm not sure what you're referring to in that log. It looks like the docs built successfully, minus one possibly spurious warning.
Upon re-reading your original post I think you're confused about the use of SAGE_KEEP_BUILT_SPKGS=yes. Your confusion is understandable--it shouldn't be outputting that message. That's just a generic message for some make target failures, but it's not applicable to the Sage documentation build.
I see now that you're saying it's getting "stuck" building the documentation. There is a known bug that the parallelized docbuild can hang in low-memory environments, which definitely is your case. You can mitigate it somewhat by running SAGE_NUM_THREADS=1 make doc. But I might suggest not building the docs on your RaspPi at all (just run make build to build everything but the docs) and, if you need to have the local HTML docs available, build them on a different system and copy them over. The Sage docbuild is very resource intensive.
@Iguananaut among your latest two comments, the former one seems like the answer to my question. Even with the simple make command with export SAGE_KEEP_BUILT_SPKGS=yes starts building the doc from the beginning though the simple make successfully completes the doc building but make -j4 doesn't. And I'll keep in mind your second suggestion.