An independent senator has won a legal bid to force the Prime Minister’s office to release secret documents it refused to show the public.