Occasionally, I have an entire workday where I get nothing done. Not a single deliverable item is checked off the list. Sometimes, it is because a task is hard and takes many days. In other cases, it is because I am unable to focus on my work.
However, I have had entire weeks go by where nothing gets finished. And, not because there is challenge in the size of a task. But, simply because something was happening in my mind which prevented me from doing my job. I really dislike this feeling. But, there is no easy way to make it go away. This week, I felt it start to happen on Monday, and by Tuesday I knew something was wrong. I just could not see what it was.
Identifying the cause of the slump can be difficult. However, if you can figure it out, then you might be able to address it and move back into a healthy mental space. In other cases, you may identify it, but it is too difficult to overcome. For example, if you are having problems in your personal life which are distracting you from your work. Or, if there is a tragedy and it makes your work feel meaningless, then you may not be able to put any real effort into your work.
In those cases, I think it is best to take time off. If that is not possible, then you should at least tell your team what is going on. You do not need to share details, just let them know that your personal life is causing distraction and that you feel as though your productivity is going to take a major hit. If you are on a good team, they will understand this and find a way to accommodate you. The project will move forward, even with your temporary leave.
If you cannot pinpoint what is causing your disability, then it might be best to just keep showing up and hoping for a better day ahead. As a programmer, one productive day can erase an entire week of slump.
Remember, if you work on a good team, they will be supportive as long as you communicate what is going on. It will be up to you whether to keep showing up to work, and that is a decision you will need to make based on the circumstances. Do not let a temporary state of confusion bring you down more than it has to. Find a way to relax - even if it is only after work - and see if clearing your mind brings you back into the zone.