Sen. John McCain (R-Ariz.) is the subject of a new documentary from HBO. (Clair Popkin/HBO/AP)

A few weeks ago, John McCain saw his life unfold before his eyes.

The Arizona senator was in a hospital room at Phoenix’s Mayo Clinic recovering from a serious intestinal procedure when Teddy Kunhardt paid a visit. The 32-year-old Kunhardt had just co-directed “John McCain: For Whom the Bell Tolls,”  about McCain’s life, and he wanted to show it to the politician.

McCain sat and watched, transfixed. When it was over he clasped the filmmaker’s hand and thanked him.

“I think I was so emotional I just ran out of the room,” Kunhardt recalled.

“It was a little — abrupt,” laughed Mark Salter, McCain’s longtime speechwriter and ghostwriter who was in the room.

The world of media and entertainment has rushed to find ways to celebrate McCain, whose brain cancer diagnosis came just 11 months ago. That celebration reaches a crescendo of sorts this weekend, as a Salter-written memoir of McCain,The Restless Wave” (which hit stores just several days ago), and “Bell” (which debuts Monday on HBO) both arrive to consumers.

Multiple mediums have been marshaled essentially to create a rare object: a living eulogy.

“We wanted John,” said “Bell” co-director Peter Kunhardt, “to see this while he still could,”

The Kunhardts (Teddy’s brother George is also a director) began to make their documentary last summer, shortly after McCain’s diagnosis. Motivated by the news of his illness and the reflective opportunities it brought (they had done a similar life retrospective on Ted Kennedy), they chose to focus on a wide sweep of the 81-year-old’s life. The filmmakers began at the start of the two-time presidential candidate’s origin story, with his birth in the Panama Canal Zone. They then move through the beats of his life, as big as they are publicized.

His service and imprisonment for years in Hanoi during the Vietnam War. His return to America and entry into politics. His three decades in the Senate with a reputation for sometimes going against his own party (the health-care speech and surprise “no” vote in July, for example).

And, of course, the two presidential runs, in the Republican primaries in 2000 against George W. Bush and as the Republican nominee in 2008 against Barack Obama. Both figures, incidentally, make appearances in the film to praise McCain, as do a wide range of other political figures, including former vice president Joe Biden, Senate pals such as Lindsey O. Graham (R-S.C.) and Joseph Lieberman and former secretary of state Henry Kissinger. (Salter himself features prominently and played a key role in development and production.)

“For Whom The Bell Tolls” — the title is a reference to the Ernest Hemingway novel and related movie, both favorites — doesn’t shy away from McCain’s mistakes, particularly his role as a so-called member of the Keating Five amid the Savings and Loan scandals of the 1980s or his campaign support of South Carolina’s hoisting the Confederate Flag outside its statehouse. But it also mostly forgives him for them, in part because McCain doesn’t forgive himself for them. A little penance goes a long way.

“What John does is say he made mistakes, and he doesn’t want to shy away, and he told us he doesn’t want to shy away,” Teddy Kunhardt said.

The film also raises, but doesn’t dwell on, McCain’s famously combustible disposition. (Biden tells The Washington Post that “John once told me he wakes up every day and prays ‘that I don’t lose my temper today.’ “)

Not much time is spent on his contentious relationship with President Trump, including staffer Kelly Sadler’s recently reported comment that McCain’s opposition didn’t matter because he was “dying anyway.”

McCain’s stance against his own party — that well-worn “maverick” label — was already highly publicized. But it is an accurate one, allies say, and should only grows with the current partisanship of Congress and between the White House and many others in Washington.

“He looms larger and larger as a person by comparison,” Lieberman said dryly in an interview.

Lieberman, a former Connecticut independent senator, also did not really take well to the Sadler comment. “It was insensitive and foolish, but we all say foolish things,” he said. “What strikes me is what they [the White House] should have done was apologize and say, ‘This is foolish.’ But they didn’t say that.”

Of that and other White House jibes, Salter said, “That crack, I don’t think it bothers John, just as with Trump’s idiotic statement three years ago that he prefers guys who weren’t captured. It doesn’t bother him because he knows it makes Trump look bad, not him. He doesn’t really care what a low-level staffer said.”

It should be noted that the movie does gloss over McCain’s fiscal conservatism and military hawkishness that has angered many on the left. And it doesn’t probe too deeply under the fundamental and long-running question about McCain: whether the maverick label is genuine or a form of marketing in its own right.

That hasn’t sat well with the senator’s critics. “[T]he political myth-making around McCain has always been tough to take, and this movie is basically two hours of it,” left-wing provocateur Matt Taibbi wrote in a scathing review of the film in Rolling Stone. “McCain has certainly fought for a lot of lost causes in his life,” he continued. “But most of them were causes he deserved to lose.”

If the portrait is gentle, it is also comprehensive, a feat especially notable given how quickly the film was made. The Kunhardts started and finished a documentary featuring a wide range of D.C. personalities and about 80 years of life, all in essentially 10 months. Even the green light came quickly: The Kunhardts pitched the movie to HBO CEO Richard Plepler — and were filming within a few weeks. “I don’t think we’ve ever seen one move as fast,” said Jacqueline Glover, the HBO executive on the project.

The book also had a quick turnaround. “The Restless Wave” was supposed to be about the past 15 years or so of McCain’s time in office, which hadn’t been covered in previous tomes. But about six months after the publishing deal was made, the senator received the diagnosis, and he and Salter decided to pivot and write a full-life retrospective. The book is on the shelves 10 months later.

“He wanted to write about issues and causes that he saw as important,” Salter said in an interview. “He wanted to talk about the traditions of the Senate that have decayed and speak directly to how we exaggerate our differences in this country. But he also just wanted to talk about what he’s learned from all his years in public service.”

The finished work includes several latter-year moments of candor, including McCain’s admission that the Iraq War, whose initiation and escalation occurred in part because of the senator’s enthusiastic support, “can’t be judged as anything other than a mistake.” He says the war was an error he had to “accept my share of the blame for.”

Salter is one of many people in the film who have been paying visits to McCain as the senator rehabilitates at his home near Sedona, Ariz.

“I was out there two weeks ago, and I’m going out in a week. It gets hard, thinking about how this is the last time for a lot of different things. The other day I was thinking this is the first time we won’t be going on this annual trip to a Munich security conference, for the first time since he was elected to Congress.” Salter paused, getting emotional. “He’s always occupied an awfully big place in the lives of the people he’s close to. It’s extremely difficult to imagine his absence. It’s unimaginable, actually.”

McCain and Biden continue to talk regularly even through the former’s illness. One subject is Biden’s late son Beau, who died of a similar form of brain cancer.

“He asks a lot about him,” Biden says. “What I learned from Beau was that when you go through a crisis the way you find your way through is by finding purpose, by being committed to something bigger than yourself. I talk about that, and John talks about that. It’s not about legacy for him — it really isn’t. It’s about: What do you have in life, what is there, if you don’t have purpose?”

When Salter has gone out, they’ve watched Westerns such as “The Man Who Shot Liberty Valance” and “Vertigo,” the Hitchcock classic. “He will have a running commentary throughout, cracking jokes,” Salter said.

Lieberman has traveled to see McCain, too, and was scheduled to make a pilgrimage to Sedona this weekend.

“When I see John he’s philosophical, in that strong way of John’s. He tells me, ‘Of course I want to live many more years. But I’ve had a wonderful life. Don’t feel sorry for me.’ ”

“John is dying like he’s lived,” Biden said. “Fighting.”